Я могу сделать это в Python:
def one(arg1):
return arg1
def two(a,b):
result=a+b
return one(result)
two(1,3)
И это будет работать. Но как я делаю то же в сценарии удара?
Попробуйте ту передачу параметров этот путь:
#!/usr/bin/env bash
function one(){
# Print the result to stdout
echo "$1"
}
function two() {
local one=$1
local two=$2
# Do arithmetic and assign the result to
# a variable named result
result=$((one + two))
# Pass the result of the arithmetic to
# the function "one" above and catch it
# in the variable $1
one "$result"
}
# Call the function "two"
two 1 3