help-bash
[Top][All Lists]
Advanced

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

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


From: Roman Rakus
Subject: Re: [Help-bash] storing a command in a variable
Date: Fri, 12 Apr 2013 20:28:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 04/12/2013 08:14 PM, address@hidden wrote:
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

log()
{
  printf '%s\n' "$@"
} >>my_log

log 'some command and fancy parameters and $(substitutions) and > redirection'
some command and fancy parameters and $(substitutions) and > redirection

or something similar.

RR



reply via email to

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