-a $HOME/.bashrc and -a ~/.bashrc produce different results

Lee Maschmeyer lee_maschmeyer@wayne.edu
Thu May 19 20:55:00 GMT 2011


Hi all,

For most uses, $HOME and ~ produce identical results. For example, ls $HOME 
or ls ~ are the same. But the following script fails:

#!/bin/bash

for i in "$HOME/.bashrc" "~/.bashrc" ; do
    echo $i
    if [ -a "$i" ]; then
 echo "-a worked"
    else
 echo "-a didn't work"
    fi

    if [ -e "$i" ]; then
 echo "-e worked"
    else
 echo "-e didn't work"
    fi
done

The $HOME cases work; the ~ cases fail.

Presumably I'm doing something nefarious but I can't figure out what. Here's 
my ID's line from /etc/passwd:

lmaschm:unused:11232:10513:Lee 
Maschmeyer,U-CIT\lmaschm,S-1-5-21-583907252-436374069-725345543-1232:/home/lmaschm:/bin/bash



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. :-)



Thanks for any help,



-- 
Lee Maschmeyer
Wayne State University Computing Center
5925 Woodward, #281
Detroit MI 48202
USA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 200262 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110519/af59844f/attachment.obj>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list