processing passwords?
Kenneth Brody
kenbrody at spamcop.net
Tue Oct 16 17:38:21 PDT 2012
On 10/16/2012 5:15 PM, Jean-Pierre A. Radley wrote:
> Kenneth Brody propounded (on Tue, Oct 16, 2012 at 10:49:46AM -0400):
> | On 10/15/2012 6:26 PM, Jean-Pierre A. Radley wrote:
[...]
> | > Your shell isn't behaving like mine, in that case. I start out in tcsh
> | > and:
> | >
> | > jpradley:appl 6 sh
I think I was partly thrown by not realizing that "jpradley:appl 6" was your
prompt, and "sh" was the command you typed to start sh.
> | > $ unset JPR
> | > $ JPR=test echo $JPR
> | >
> | > $ echo $JPR
> | > test
> |
> | I hate to do it, but I have to side with Jay against JP on this one. My
> | understanding has always been that "name=val command" sets the value of the
> | environment variable only for "command", and not in the shell. It's been
> | this way since at least TRS-Xenix days. In fact, "man sh" on my Linux box says:
> |
> | > The environment for any simple command or function may be
> | > augmented temporarily by prefixing it with parameter
> | > assignments, as described above in PARAMETERS. These
> | > assignment statements affect only the environment seen by
> | > that command.
> |
> | What does "echo $JPR" say *before* the echo command?
>
> Don't follow you, Ken.
>
> The comand "JPR=test echo $JPR" produces just a newline.
>
> The next command shows that the assignment (JPR=test) before the command
> (echo $JPR) persists in the invoking shell, because the next command
> (echo $JPR) prints "test".
Note that I only get the behavior you show when using SCO's version of sh,
and only if the command is a shell built-in, such as "echo".
========== SCO's /bin/sh
# echo $0
-sh
# unset JPR
# JPR=test echo $JPR
# echo $JPR
test
# unset JPR
# JPR=test ls -ld /tmp
drwxrwxrwt 4 bin bin 8192 Oct 16 20:11 /tmp
# echo $JPR
#
========== SCO's /bin/bash
# bash
bash-2.05a# unset JPR
bash-2.05a# JPR=test echo $JPR
bash-2.05a# echo $JPR
bash-2.05a#
========== FreeBSD's /bin/sh
Moon5.6 (/dev/pts/0) > sh
Moon5.6 (/dev/pts/0) > ls -l /bin/*sh
-r-xr-xr-x 2 root wheel 328384 Apr 9 2012 /bin/csh
-r-xr-xr-x 1 root wheel 118512 Apr 9 2012 /bin/sh
-r-xr-xr-x 2 root wheel 328384 Apr 9 2012 /bin/tcsh
Moon5.6 (/dev/pts/0) > unset JPR
Moon5.6 (/dev/pts/0) > JPR=test echo $JPR
Moon5.6 (/dev/pts/0) > echo $JPR
Moon5.6 (/dev/pts/0) >
========== Linux's /bin/sh (a symlink to bash)
Moon5.6 (/dev/pts/2) > sh
Moon5.6 (/dev/pts/2) > ls -l /bin/*sh
-rwxr-xr-x. 1 root root 877480 Jun 22 2010 /bin/bash
lrwxrwxrwx. 1 root root 4 Feb 29 2012 /bin/csh -> tcsh
-rwxr-xr-x. 1 root root 102216 Dec 2 2009 /bin/dash
lrwxrwxrwx. 1 root root 4 Mar 8 2012 /bin/ksh -> bash
lrwxrwxrwx. 1 root root 4 Feb 29 2012 /bin/sh -> bash
-rwxr-xr-x. 1 root root 380392 Jun 21 2010 /bin/tcsh
Moon5.6 (/dev/pts/2) > unset JPR
Moon5.6 (/dev/pts/2) > JPR=test echo $JPR
Moon5.6 (/dev/pts/2) > echo $JPR
Moon5.6 (/dev/pts/2) >
==========
Ah... A "man sh" on a SCO box reveals this tidbit, not seen on other systems:
> The environment for any simple-command may be augmented by prefixing
> it with one or more assignments to parameters. Thus:
> TERM=450 cmd
>
> and
> (export TERM; TERM=450; cmd)
>
> are equivalent as far as the execution of cmd is concerned if cmd is
> not a ``special command'' (see ``Special commands''). If cmd is a
> special command, then
> TERM=450 cmd
>
> will modify the TERM variable in the current shell.
--
Kenneth Brody
More information about the Filepro-list
mailing list