Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Apr 2017 16:08:32 +0200
From:      Stefan Esser <se@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        luzar722@gmail.com
Subject:   Re: csh script help
Message-ID:  <2b66121b-2bec-81fd-4281-7cf02dae7434@freebsd.org>
In-Reply-To: <58F0D301.7000509@gmail.com>
References:  <58F0D301.7000509@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Am 14.04.17 um 15:47 schrieb Ernie Luzar:
> To aid in debugging the script I'm writing, I place "echo" commands
> throughout so I can kind of have a trace of the logic as different
> conditions are processed. Normally I just delete these "echo" commands
> after I get the script working.
> 
> But this time I want to try something different. I want to
> enable/disable the echo commands in mass. So in the beginning of the
> script I added these 2 lints.
> 
> #trace=""  # use to enable trace echo
> trace="#"  # use to disable trace echo
> 
> In front of each of the echo commands I added this,
>  $trace echo "what ever."
> 
> When I exec the script I get error message  #: not found

This is to be expected ;-)

> What is happing here? Is the substitution to late?

No.

> Is there a way to fix this?

Use ":" instead of "#" to insert a "null command" before the echo:

% set trace=""
% $trace echo Hello
Hello
% set trace=":"
% $trace echo Hello
%

Regards, STefan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2b66121b-2bec-81fd-4281-7cf02dae7434>