Re: Passing parmaters to a shell script

From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 05/28/04


Date: Fri, 28 May 2004 15:28:58 +0000

2004-05-28, 07:06(-07), Stu:
> I have the following shell script:
>
> cat t.sh
> ==========
> spec="SPEC='C:\tmp\00000291.s00'"
> sh t1.sh "${spec}"
>
> that calls t1.sh
>
> cat t1.sh
> set -x
> echo "|$1|"

echo can't be use to display arbitrary data as it expands escape
sequences (here \t for tab). Moreover, it's one of the least
portable commands, some of them even accept options (you can't
display "-n" then for instance). It's a command to avoid in
scripts except to display constant strings (litterals).

Use printf instead:

printf '%s\n' "|$1|"

-- 
Stephane


Relevant Pages

  • Display text in canvas
    ... I'm trying to pull the contents of a text widget and display it in a ... canvas using the same font as the text widget. ... Specify the configuration file to use; ... This can be meaningful if the cat page was ...
    (comp.lang.tcl)
  • Re: Read-only error message?
    ... > Please excuse this message if this is an obvious question to ask, ... > am relative Matlab neophyte. ... > typing "x.y" at the prompt should display my data nicely. ... The best material model of a cat is another, or preferably the same, cat. ...
    (comp.soft-sys.matlab)
  • Re: problem with Xorg
    ... cat /var/log/Xorg.0.log | grep EE ... NIVIDIA: Multiple displays connected, ...
    (Ubuntu)
  • Re: Shell scripting question
    ... Example code for the moving |/-\ would be excellent as this is exactly what ... >> shell script, I have a large shell script which can take some time to ... >> and I was to display some activity for the user to see while the script ... > Trog Woolley | trog at trogwoolley dot com ...
    (linux.redhat)
  • Re: (screen) problem with terminal wraparound
    ... If I use something like 'less' to display the file, ... I.e., I think 'less' honors the "stty" settings, but somehow ... 'cat' does not. ... If you pipe the above gawk command line into 'less' then everything is ...
    (comp.unix.shell)