I have two un开发者_C百科ix machines, both running AIX 5.3
My $HOME is mounted on machine1. Using NFS, login machine2 will go to the same $HOMEI login machine2 first, then machine1.
Both using telnet.The 2 sessions will share the same .sh_history file.
I found out that the fc -l behavior very strange.
In machine2, I issue the commands in telnet:
fc -l
ksh fc -l
Both give the same output.
In machine1,
fc -l
ksh fc -l
give DIFFERENT results
The result forksh fc -l
is the same as /usr/bin/fc -l
Also, when I run a script like this:
#!/usr/bin/ksh
fc -l
The result is same as /usr/bin/fc -l
Could anyone tell me what happened?
Alvin SIU
Ah, wisdom of the ancients... (Since this post is over a year old.)
Anyway, I just encountered this problem in Solaris 10. Issue seems to be this: When you define a function in /etc/profile
, or in any file called by /etc/profile
, your HISTFILE
variable gets ignored by the Korn shell, and the shell instead uses ".sh_history"
when accessing its history. Not sure why this is.
Result is that you see other root shell's commands. You can test it with :
lsof -p $$
or
cat /proc/$$/fd/63
It's possible that the login shell is not ksh or that $HISTFILE
is being reset. One thing you can do is echo $HISTFILE
in the various situations and see if it's different. Another thing to check is to see what shell you're in using ps
.
Bash (default $HOME/.bash_history
), for example, will have a different $HISTFILE
than ksh (default $HOME/.sh_history
).
Another possible reason for the difference is that the builtin fc
may be able to see in-memory history that hasn't been written to disk yet (which the external /usr/bin/fc
wouldn't be able to see). If this is true, it may be version dependent. Bash, for example, doesn't write history to the file until the shell exits. Ksh (at least the version I'm using) writes it immediately.
精彩评论