> In the man pages for alias:
> With -x, set exported aliases. An exported alias is defined
> across subshell environments. With name=value omitted, print the
> list of exported aliases in the form name=value on standard
> output.
> If I create an alias with the -x option and spawn a child shell,
> $ alias -x da="net"
> $ alias -x
> da=net
> $ sh
> $ alias
> /* the alias is not going to be available. How to make it available in a new
> (child) shell session? */
> $ exit
> Thanks.
When you invoke "sh" you start a whole new shell, not a subshell.
Similarly, a whole new shell is invoked when you start a script
with a hashbang (shebang) as the first line:
#!/usr/bin/ksh
Subshells are started:
when shells are executed and they do not have a shebang
when the list is placed in parentheses; e.g.:
(cd /tmp;tar zxvf $file)
implicitly, as part of a pipeline:
{ cd /tmp;ls -l } | while read p l u g s d1 d2 file;...
in all shells, the cd and ls will be run in a subshell. In all
bournish shells but ksh and zsh, the while loop will run in a
subshell.
The use of exported aliases is deprecated in ksh88 and removed in
ksh93 basically because it's not a real good practice. What are you
really trying to do?
--
Dan Mercer
Opinions expressed herein are my own and may not represent those of my employer.