[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] storing a command in a variable

From: John Kearney
Subject: Re: [Help-bash] storing a command in a variable
Date: Sat, 13 Apr 2013 01:47:58 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5

Am 12.04.2013 20:14, schrieb address@hidden:
> Often I do something like
> cmd="command arg"
> echo "${cmd}" >>my_log
> eval "${cmd}" 2>&1 >>my_log
> and many times I have read on this list that storing a command in a
> variable is a bad thing to do
> What is a better/safer way of doing this
> Richard
I normally advise

run_cmd() {
    local RValue=0
    printf "%q" "address@hidden"; echo
    "address@hidden" || RValue=$?
    [ ${RValue} = 0  ] || echo "Returned (${RValue}) ${*}"
    return ${RValue}

run_cmd command arg

reply via email to

[Prev in Thread] Current Thread [Next in Thread]