-a $HOME/.bashrc and -a ~/.bashrc produce different results
Eric Blake
eblake@redhat.com
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 eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110519/dd278089/attachment.sig>
More information about the Cygwin
mailing list