bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No tilde expansion right after a quotation


From: Angel Tsankov
Subject: Re: No tilde expansion right after a quotation
Date: Mon, 16 Feb 2009 01:13:36 +0200

Jon Seymour wrote:
> If you are willing to trade conciseness in order to eliminate use of
> builtin commands, you can use.
>
>  local tmp=~usr1/blah/blah
>  CPATH="${CPATH}${CPATH:+:}${tmp}"
>
> However, if you are concerned about echo failing, then you also need
> to be concerned about local failing.
>
> Hence:
>
>  local tmp=~usr1/blah/bah
>  [ $? -eq 0 ] || ... do something
>  CPATH="${CPATH}${CPATH:+:}${tmp}"
>
> However, that is taking defensive programming to absurd levels.
>
> If the builtin echo fails it will be because the bash interpreter has
> suffered a catastrophic failure of some kind [ e.g. run out of memory
> ]. Once that has happened, all bets are off anyway.
>
> To be honest, it seems to me that your reluctance to use $(echo
> ~usr1/blah/blah) is rooted in an aesthetic objection or perhaps a lack
> of familiarity with the command substitution idiom. If the latter, I'd
> encourage you to reconsider, since command substitution is one of
> bash's most powerful features.
>
> [ Of course, others more experienced with bash idioms may object to
> $(echo ~usr1/blah/blah)  on aesthetic grounds too - I welcome any
> suggested improvement!. ]
>
> jon.

Thanks for your replies,
Angel Tsankov 







reply via email to

[Prev in Thread] Current Thread [Next in Thread]