alias problem

alias problem

Post by Fayerma » Wed, 18 Apr 2001 01:13:41



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.

 
 
 

alias problem

Post by Dan Merc » Wed, 18 Apr 2001 01:40:11




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

 
 
 

alias problem

Post by Fayerma » Wed, 18 Apr 2001 03:22:16


Quote:> 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:

When the script is started with something like #!/usr/bin/ksh, it is not
going to invoke a whole new shell. It just tells us to substitute the
original call to 'exec' (before every command) with the specified
interpreter (#!/usr/bin/ksh). I guess it will be done for every command
individually. However, I understand that this is not a subshell.

Quote:> 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?

Just want to have my aliases to be available when starting a new shell.

Thanks.

 
 
 

alias problem

Post by Dan Merc » Wed, 18 Apr 2001 05:28:48




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

> When the script is started with something like #!/usr/bin/ksh, it is not
> going to invoke a whole new shell. It just tells us to substitute the
> original call to 'exec' (before every command) with the specified
> interpreter (#!/usr/bin/ksh). I guess it will be done for every command
> individually. However, I understand that this is not a subshell.

When the shell goes to run an external command,  it calls exec.
Exec recognizes the magic number (#!) and execs the file pointed
to by the path following the shebang.  If it is a script file and there
is no shebang,  exec fails.  It is up to the shell to decide what to
do with the file.  Bournish shells will fork using the file
as input - a subshell.  The details for Korn shells are more complicated,
particularly in handling aliases,  functions and non-scalar variables.

Quote:

>> 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?

> Just want to have my aliases to be available when starting a new shell.

> Thanks.

Then put them in your $ENV file. That's what it's for.

--
Dan Mercer

Opinions expressed herein are my own and may not represent those of my employer.

 
 
 

alias problem

Post by Michael Heimin » Wed, 18 Apr 2001 06:54:21





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

> > When the script is started with something like #!/usr/bin/ksh, it is not
> > going to invoke a whole new shell. It just tells us to substitute the
> > original call to 'exec' (before every command) with the specified
> > interpreter (#!/usr/bin/ksh). I guess it will be done for every command
> > individually. However, I understand that this is not a subshell.

> When the shell goes to run an external command,  it calls exec.
> Exec recognizes the magic number (#!) and execs the file pointed
> to by the path following the shebang.  If it is a script file and there
> is no shebang,  exec fails.  It is up to the shell to decide what to
> do with the file.  Bournish shells will fork using the file
> as input - a subshell.  The details for Korn shells are more complicated,
> particularly in handling aliases,  functions and non-scalar variables.

> >> 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?

> > Just want to have my aliases to be available when starting a new shell.

> > Thanks.

> Then put them in your $ENV file. That's what it's for.

> --
> Dan Mercer

In addition, I don't now which version of ps the OP uses.

With (procps version 2.0.6) "ps -faux" shows what you described,
very nice...

Michael Heiming

 
 
 

1. script alias problem - Re: apache alias and script alias problem

I actually did not have the <Directory> setup properly.

I am still having a problem with the script alias.

For example.

I set an alias -

Alias / /home/user1/html/

and a Script Alias -
ScriptAlias /cgi-bin/ /home/user/cgi-bin/

However the script alias is not working because the log shows that
when entering:
http://localhost/cgi-bin/

/home/user/html/cgi-bin/ is actually being referenced.

When I remove the first Alias statement the cgi-bin script directory
is properly aliased.

Any suggestions.

Thanks.

---
Andrew

Please remove TOREMOVE chars to e-mail me

2. SPICE FOR LINUX?

3. apache alias and script alias problem

4. Yet another cron problem?

5. possible cache aliasing problem with O_DIRECT?

6. Solaris 2.4 nfsd problems

7. IP aliasing Problem

8. Appropriate admin response

9. ifconfig alias problem

10. Linux 2.0.0 IP Aliasing Problem

11. Alias problem (Part 2)

12. wu-ftpd and cname alias problems

13. No Login Script / Alias problems on Remote Host