1

What are the advantages of aliasing a directory (in my .profile) as opposed to setting a shell variable to it (and exporting of course).

alias MY_DIR=/usr/local/data/test/

vs

MY_DIR=/usr/local/data/test/
export MY_DIR
C. Ross
  • 3,075
  • 9
  • 35
  • 36

1 Answers1

4

The alias only works for commands. That is, the shell will check argv[0] for aliases, it will check every part of argv for sigiled variables (like $MY_DIR). A visual demonstration:

g3 0 /home/jj33 > alias FOO=bar
g3 0 /home/jj33 > FOO
-ksh: bar: not found
g3 127 /home/jj33 > echo FOO
FOO
g3 0 /home/jj33 > BAZ=bar
g3 0 /home/jj33 > $BAZ
-ksh: bar: not found
g3 127 /home/jj33 > echo $BAZ
bar
jj33
  • 11,178
  • 1
  • 37
  • 50