There may be other ways to do this, but: CPATH="${CPATH}${CPATH:+:}$(echo ~usr1/blah/blah)"
should work. jon. On Mon, Feb 16, 2009 at 9:02 AM, Angel Tsankov <fn42...@fmi.uni-sofia.bg> wrote: > Chet Ramey wrote: >> Angel Tsankov wrote: >>> Hi, >>> >>> Using bash 3.2.48(1)-release, echo ""~root prints ~root instead of >>> /root. Is this the expected behaviour? >> >> Yes. The tilde is not the first character in the word. Portions of >> words to be tilde-expanded can't be quoted at all, either. > > I see. I came to this example from a real-world problem and, in case > someone can help, here it is. I'd like to append a path to CPATH > (separating it from the current contents of CPATH with a colon only if CPATH > is set and is not empty). The path-to-append points under usr1's home > directory. Also this should work in contexts such as CPATH=... <some > command>. I tried CPATH="${CPATH}${CPATH:+:}"~usr1/blah/blah. (I quote > expansions just to be on the safe side, though I think home directories may > not contain spaces.) Of course, this did not work for the reason pointed > above. However, removing the quotes still does not make the > tilde-expression to expand. How can I achieve my goal? > > Regards, > Angel Tsankov > > > > > >