bug-bash
[Top][All Lists]
Advanced

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

Re: invoke tilde expansion on quoted string


From: Greg Wooledge
Subject: Re: invoke tilde expansion on quoted string
Date: Mon, 12 Dec 2011 08:27:19 -0500
User-agent: Mutt/1.4.2.3i

On Sun, Dec 11, 2011 at 04:28:49PM +0800, Yang Chengwei wrote:
> On Sat, Nov 12, 2011 at 01:42:16PM +0800, Peng Yu wrote:
> > I'm wondering if I already have a string variable, is there a bash
> > native to do tilde expansion on it.
> > 
> > var='~/..'
> > cd $var#how to change this line?

It sounds like this example does not correctly represent the problem.

> If you just want to tilde expansion, how about let it unquoted? Just
> like below.
> 
> var=~chengwei/Dir
> cd $var

There is absolutely no reason to skip the quoting here:

imadev:~$ var=~liup/bin
imadev:~$ echo "$var"
/net/home/liup/bin

The tilde expansion occurs during the assignment to var, so "$var" should
be properly double-quoted when it's used.



reply via email to

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