valdi@rhi.hi.is (Thorvaldur Sigurdsson) (03/20/90)
Background: The following was done on a HP 9000/360 with the
Korn shell (vers. 62.2 from what /bin/ksh) and HP-UX 6.5.
.profile
# This is a KornShell login profile
# Set and export the following
export EDITOR=vi \
ENV=$HOME/.envfile
.envfile
# This is a environment file
set -o ignoreeof markdirs
alias ls='lsf'
stty intr kill
demo_arg
#!/bin/ksh
echo $0
echo $1
echo $2
chmod +x demo_arg
demo_arg var1 var2
Expected results:
./demo_arg
var1
var2
Execution result:
./demo_arg
markdirs
The expected results can be acheived if "set -o ignoreeof markdirs" is in the
.profile. Another solution is to change in .envfile :
set -o ignoreeof markdirs
to
set -o ignoreeof
set -o markdirs
It seems to be unlegal to have the command "set -o ignoreeof markdirs" in .envfile.
Why ?
Glossary:
markdirs : ksh appends a trailing / to all directory names resulting
from pathname expansion.
ignoreeof : When the interactive option is also set, ksh does not exit
on End-of-file (default CTRL-d). Type "exit" to terminate
ksh.
________________________________________________________________________
| Thorvaldur Egill Sigurdsson | Internet: valdi@kerfi.hi.is |
| Engineering Research Institute | |
| University of ICELAND | Phone: 354-1-694699 |
| Hjardarhagi 2-6 | |
| 107 Reykjavik, ICELAND | |
------------------------------------------------------------------------shankar@hpclscu.HP.COM (Shankar Unni) (03/22/90)
> set -o ignoreeof markdirs > to > set -o ignoreeof > set -o markdirs > Yes. The syntax for "set" builtin in ksh require one "-o" for *each* option that you are setting, as in: set -o ignoreeof -o markdirs Otherwise, what your example did is the same as set -o ignoreeof set markdirs The second command has the effect of setting $* to the value "markdirs". ----- Shankar Unni E-Mail: Hewlett-Packard California Language Lab. Internet: shankar@hpda.hp.com Phone : (408) 447-5797 UUCP: ...!hplabs!hpda!shankar
rpt@hpfcdc.HP.COM (Rich Testardi) (03/22/90)
> It seems to be unlegal to have the command "set -o ignoreeof markdirs" > in .envfile. Why ? From the ksh(1) man-page: > -o The -o argument takes any of several > option names, but only one option can > be specified with each -o flag. ... > The remaining arg arguments are positional > parameters and are assigned consecutively to > $1, $2, .... Ksh needs to *unambiguously* decide where the -o options end and where the positional parameters begin -- it does so by restricting you to exactly *one* option per "-o" flag. When you say "set -o ignoreeof markdirs", ksh thinks you want to enable "ignoreeof" and then set $1 to "markdirs" (and clear $2, $3, etc.)... As a side note: You might consider changing the "#!/bin/ksh" in your scripts to a "#!/bin/ksh -p" -- this will prevent them from sourcing the $ENV file altogether (a *very* common source of problems for ksh scripts), and instead, cause them to source /etc/suid_profile (if it exists). Hope this explains the behavior. -- Rich