The manual describes the rule: Work with the partition shell .
You will read:
The following is a brief description of a shell operation when it reads and executes a command. Basically, a shell performs the following actions:
, script:
#! /bin/bash
$1 sleep 3
./script "echo hello ;"?
- Bash script.
- . , Bash
;, echo hello ;.
$1, sleep 3. - . .
- :
$1 echo, hello ; ( , , , 2 ). - .
- Bash :
echo hello, ;, sleep 3. hello ; sleep 3. - ( )
echo.
: - eval, : script
#!/bin/bash
eval "$1 sleep 3"
script:
$ ./script "echo hello;"
hello
$
( 3 ). ./script "echo hello &&". . .
, ( , Bash) : (), . . , , - , , , , "". , *, ./script "echo \"*\";". .
. :
say_hello_and_execute() {
echo hello; "$@"
}
: export -f say_hello_and_execute script: ./script say_hello_and_execute.
script: script say_hello_and_execute:
#!/bin/bash
echo hello; "$@"
chmod +x say_hello_and_execute script ./script ./say_hello_and_execute.
. , , , , .