I have been idle for the past two days, playing Nb, starting with shell, and coming up with something interesting. Remember it by the way.
A simple script test_2 is written to output the user's parameters:
#! /Bin/sh
If [$ #-lt 2]; then
Echo "you need 2 paramerters at less! "
Exit 0
Fi
One = "$1"
Two = "$2"
Echo "Your paramerters are :"
Echo $1
Echo $2
: WQ save;
Chmod + x test_2 make it executable
The execution results of different parameters are as follows:
(1) No parameters:
#./Test_2
You need 2 paramerters at less!
(2)
#./Test_2/43./# $ @&
# Your paramerters are:
/43
./#
---------------------------------------------------------------
No prompt appears. It seems that the command has not been executed.
/*
* It may be because of the special meaning of the last character "&", which is unknown for the moment.
*/
Press enter directly:
[1] Done./test_2/43./# $ {@}
(3)
#./Test_2/43./# $ @
# Your paramerters are:
/43
./#
#
----------------------------------------------------------------
It is the same as the previous output, but a command prompt is displayed, indicating that the command has been executed.
(4)
#./Test_2/43./# $
# Your paramerters are:
/43
./# $
#
----------------------------------------------------------------
It seems to be a normal output. It is normal to remove "@". It is strange.
(5)
#./Test_2/43 ./#
# Your paramerters are:
/43
./#
#
----------------------------------------------------------------
Still normal.
"./Test_2/43./" and "./test_2/43." are normal.
(6)
#./Test_2/43./# $ &
# Your paramerters are:
/43
./# $
-----------------------------------------------------------------
If no prompt is displayed, "./test_2/43./# $" is normal. It seems that this conclusion can be made: "&" can continue execution only after user input. It is not clear what to enter.
(7)
#./Test_2/43./$ @
# Your paramerters are:
/43
./
#
-----------------------------------------------------------------
Compared with case 3, it seems that "$ @" is ignored.
(8)
#./Test_2/43./$4 @
# Your paramerters are:
/43
./@
#
-----------------------------------------------------------------
It's so strange that the headers are all big.
I guess it is normal that shell processes some special characters when passing parameters so that they cannot be directly used as parameters. I probably didn't see the source code and didn't know the rules.