Как передать аргументы от одной функции до другой функции в сценариях удара?

Я могу сделать это в Python:

def one(arg1):
    return arg1

def two(a,b):
    result=a+b
    return one(result)

two(1,3)

И это будет работать. Но как я делаю то же в сценарии удара?

0
задан 13 August 2018 в 05:59

1 ответ

Попробуйте ту передачу параметров этот путь:

#!/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
2
ответ дан 28 October 2019 в 04:10

Другие вопросы по тегам:

Похожие вопросы: