Am 20.03.2015 um 03:05 schrieb Hongyi Zhao:
> On Fri, 20 Mar 2015 01:55:51 +0100, Janis Papanagnou wrote:
>
>> dig --arg1 \
>> $(: --arg2) \
>> --arg3
>
> Still not so clear how to adapt for my case, say, the following command:
>
>
> nmap -T4 \
> --min-hostgroup 500 \
> --min-parallelism 5000 \
> --max-retries 1 \
> --host-timeout 60 \
> <target>
>
>
> If I want to commented out the `--max-retries 1', then how should I
> revise it based on your above method?
You would put $(: and ) around the respective option settings:
$(: --max-retries 1 ) \
But, to be honest, this is fancy but I don't think this is a good idea,
since you'd have to make changes at two places in the considered lines.
My (serious) approach would probably go into another direction; like
MAX_RETRIES="--max-retries 1"
# and similar definitions with other options
#
nmap -T4 \
--min-hostgroup 500 \
--min-parallelism 5000 \
${MAX_RETRIES} \
--host-timeout 60 \
<target>
And if you don't want a particular option in the command then put a
comment, a single #, where the variable has been assigned.
A variation of this, to keep the assignments clean, may be to not
specify the option name in the assignment but conditionally expand
it where it's called; as in:
X=1
# Y=42
Z=99
your_cmd "${X:+xoptname $X}" "${Y:+yoptname $Y}" "${Z:+zoptname $Z}"
If that's confusing to you, that would be with your option names:
MAX_RETRIES=1
nmap -T4 \
... \
${MAX_RETRIES:+ --max-retries ${MAX_RETRIES}} \
... \
<target>
And, as above, just comment out the assignment line(s).
Janis
>
> Regards
>