I'm coding a shell as school project. In builtins there is a "history" command and some options, like '-c' for cleaning or '-s' for adding args on the history. One of the option is '-p' and the man say :
-p Perform history substitution on the args and display the result on the standard output, without storing the results in the history list.
I really don't understand what this option do. When i try it, it show the args and do nothing more.
Does someone know ?
-p Perform history substitution on the args and display the result on the standard output, without storing the results in the history list.
Here is example, which illustrates what it does actually
# clear history
$ history -c
# call date - this will be saved in history
$ date
Tue Oct 3 23:47:24 IST 2017
# call call - this also will be saved in history
$ cal
October 2017
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
# see what all saved so far
$ history
996 date
997 cal
998 history
# see this prints string on stdout, but doesn't save in history
$ history -p "This is test string which is not stored in history"
This is test string which is not stored in history
# as you can see history -p "....." is missing
$ history
996 date
997 cal
998 history