-a $HOME/.bashrc and -a ~/.bashrc produce different results
Thu May 19 21:06:00 GMT 2011
On 05/19/2011 02:54 PM, Lee Maschmeyer wrote:
> Hi all,
> For most uses, $HOME and ~ produce identical results. For example, ls
> $HOME or ls ~ are the same. But the following script fails:
> Presumably I'm doing something nefarious but I can't figure out what.
I can. And it's not cygwin-specific.
> for i in "$HOME/.bashrc" "~/.bashrc" ; do
"$HOME" expands $HOME, but "~/.bashrc" does _not_ expand ~. For
tilde-expansion to occur, it must be unquoted.
> if [ -a "$i" ]; then
Use 'set -vx' to see what was really run. The first iteration ran:
'[' '-a' '/home/blah/.bashrc' ']'
while the second ran:
'[' '-a' '~/.bashrc' ']'
> As far as I can tell I've done everything right, but I can't believe
> I've discovered a bug! I think I _am_ the bug. :-)
Correct assumption, for once :)
Eric Blake firstname.lastname@example.org +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 619 bytes
Desc: OpenPGP digital signature
More information about the Cygwin