Solved Searching for a specific builtin command's manual page (history)

I'm looking for the history command's manual page but cant find it, when man history is enter at the prompt it show the built-ins manpage which says to look for the specific manual page for the command??? kind of an infinite loop for dummie here.
 
Man(1) pages are typcially for commands, file formats, device drivers, etc.

A "builtin" command is BUILT INTO something -- a shell. So, you would find its documentation in the man page for that shell.
 
[…] So look at the man page for what ever shell you are using.
To put this into a command line:​
sh:
man $0
But then you might be confronted with the fact that for instance zsh(1) splits its manual page into separate pages. 😩
I'm looking for the history command's manual page but cant find it, […]
history (without any arguments) is (usually) equivalent to fc -l so if you like you can read the POSIX™ description of fc (although your shell might not comply with POSIX™).​
 
In builtin(1) it says that history isn't part of the sh shell, In sh(1) I found that I can set $HISTFILE and $HISTSIZE and if the first variable isn't set sh use by default the file ~/.sh_history. I went on to set these two variable in the ~/.profile, restarted ~/.shrc but it doesn't seem to take effect. .history is still empty and when entering history in the prompt I get the 10 last entry or so of I don't know which file, because I deleted the content of the ~/.sh_history and history isn't supposed to be integrated in the sh shell according to the man so ?

sh:
cat .profile
#
# .profile - Bourne Shell startup script for login shells
#
# see also sh(1), environ(7).
#

# These are normally set through /etc/login.conf.  You may override them here
# if wanted.
# PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$HOME/bin; export PATH

# Setting TERM is normally done through /etc/ttys.  Do only override
# if you're sure that you'll never log in via telnet or xterm or a
# serial line.
# TERM=xterm;   export TERM

EDITOR=vi;      export EDITOR
PAGER=less;     export PAGER
HISTFILE=~/.history; export HISTFILE
HISTSIZE=1000;  export HISTSIZE

# set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.shrc; export ENV

# Let sh(1) know it's at home, despite /home being a symlink.
if [ "$PWD" != "$HOME" ] && [ "$PWD" -ef "$HOME" ] ; then cd ; fi

# Query terminal size; useful for serial lines.
if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi

# Display a random cookie on each login.
if [ -x /usr/bin/fortune ] ; then /usr/bin/fortune freebsd-tips ; fi
 
FreeBSD's /bin/sh does not have history(1) as a command.

But it writes its history to a file.
why then when input history it output the last few entries and to which file since the content of the default file sh use for that matter according to the man has been emptied by me??
 


Code:
~ $ history
  463 clear
  464 history
  465 man builtin
  466 clear
  467 cat .profile
  468 man fc
  469 fc -l
  470 clear
  471 less .sh_history
  472 less .history
  473 vi .history
  474 clear
  475 vi .sh_history
  476 clear
  477 history
  478 clear
~ $

[Edit]

Never mind, it write the entry to the file I have set as a variable of $HISTFILE . It took some time to come into effect. But I still dont understand why when I input in the prompt the command history it work since it isn't supposed to be implemented in sh and where is the documentation for that command.
 
Well, in your environment type history might report something like​
Code:
history is an alias for fc -l -10
I didn't set it this way myself, it's confusing, why make an alias when fc(1) is doing the same thing? can we confirm that there is an alias? I would have preferred a "not found" me too. So this way I would have found immediately that sh use fc(1) and the relative documentation to it in sh(1)
 
Never mind, it write the entry to the file I have set as a variable of $HISTFILE . It took some time to come into effect. But I still dont understand why when I input in the prompt the command history it work since it isn't supposed to be implemented in sh and where is the documentation for that command.
Dicking with environment variables (envars) is confusing to many. This is a consequence of the shell and how it works for you.

# echo $HOME
/root
# set HOME=12345
# echo $HOME
/root

Gee, what happened to that "12345" setting?

Ans: that was the value of HOME in the instance of the shell that processed your "set HOME" command. But, that shell instance has now terminated (successfully!) and you are back in the original shell -- where $HOME is still /root.

If you want to make changes to envars in THIS shell instance:

# export set HOME=12345
# echo $HOME
12345

[The whole notion that there isn't ONE shell (instance) that processes all of your commands is something that takes time to wrap your head around.]
 
why make an alias when fc(1) is doing the same thing
Aliases (called "active functions" in the wayback) are a powerful shorthand. Think of them as mini "programs" (scripts) that you can invoke from the command line.

So, if you are always in the habit of typing "ls -al", you could create an alias -- ll or maybe dir -- that does this for you.

Aliases are your friends.
 
Take a look at this thread where we were talking about it.
 
I didn't set it this way myself, it's confusing, […] can we confirm that there is an alias?
sh:
grep -F 'alias history' $ENV
[…] why make an alias when fc(1) is doing the same thing? […]
I don’t know. Nostalgia? According to WP history appeared in early UNIX versions, yet if you look at the version history of above linked files you see Baptiste Daroussin added the aliases only a couple years ago.​
 
Dicking with environment variables (envars) is confusing to many. This is a consequence of the shell and how it works for you.

# echo $HOME
/root
# set HOME=12345
# echo $HOME
/root

Gee, what happened to that "12345" setting?

Ans: that was the value of HOME in the instance of the shell that processed your "set HOME" command. But, that shell instance has now terminated (successfully!) and you are back in the original shell -- where $HOME is still /root.

If you want to make changes to envars in THIS shell instance:

# export set HOME=12345
# echo $HOME
12345

[The whole notion that there isn't ONE shell (instance) that processes all of your commands is something that takes time to wrap your head around.]
I suppose it's true, one have to remember it but one need lots of experience to do it. thanks for clarification.
 
Back
Top