Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #166837

Re: My script almost works but spams the terminal its launched from if useing dash.

From "Thomas Schmitt" <scdbackup@gmx.net>
Newsgroups linux.debian.user
Subject Re: My script almost works but spams the terminal its launched from if useing dash.
Date 2016-04-17 16:40 +0200
Message-ID <roW1I-5QE-9@gated-at.bofh.it> (permalink)
References <roUMi-4TN-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi,

Gene Heskett wrote:
> they do not have enough voltage 
> across the oxide film to keep it "formed" so the oxide slowly reverts as 
> its in an oxygen free environment

I always preferred math over chemistry.


> So I should change my single quotes to double-quotes.

Rather not. At least not as general advise. Beware.


The single '-quotes enclose constants (with special meaning of $'...',
in bash but not in dash).
Their use case is to keep whitespace or special characters from being
converted.
'gene' does not really need them, because it is only one word.
But 'Gene Heskett' or ';(|[$' would need them to be handled as a single
argument to some program run or to avoid shell parser complaints.

  $ echo ;(|[$
  bash: syntax error near unexpected token `|'
  $ echo ';(|[$'
  ;(|[$

In bash only:

  $ echo $'xyz\010abc'
  xyabc

(octal 010 = decimal 8 = ASCII BS backspace did eat the "z")


The double "-quotes should often be put around variable evaluations in
order to make the variable content a single argument to some program
run. These quotation marks protect whitespace and some special
characters. But they do not prevent variable evaluation and similar
text conversions.

man bash says:

  Enclosing  characters  in  double quotes preserves the literal value of
  all characters within the quotes, with the exception of $, `,  \,  and,
  when  history  expansion  is enabled, !.  The characters $ and ` retain
  their special meaning within double quotes.  The backslash retains  its
  special  meaning only when followed by one of the following characters:
  $, `, ", \, or <newline>.  A double quote may be quoted  within  double
  quotes by preceding it with a backslash.  If enabled, history expansion
  will be performed unless an !  appearing in double  quotes  is  escaped
  using a backslash.  The backslash preceding the !  is not removed.

One may put each variable into its own "-pair or one may mix constant
text and variable evaluation inside a one pair of "-quotes.

I use the for-loop to demonstrate content and number of perceived
program arguments. Any program or sub script will see the words
between "in" and the first ";" as the argument list which is printed
here by the for-loops.
The appended echo commands produce spacer lines for better readbility.

  $ for i in a b c ; do echo "$i" ; done ; echo
  a
  b
  c

  $ x='X  Y  Z'
  $ for i in a $x c ; do echo "$i" ; done ; echo
  a
  X
  Y
  Z
  c

  $ for i in a "$x" c ; do echo "$i" ; done ; echo
  a
  X  Y  Z
  c

  $ for i in "a $x c" ; do echo "$i" ; done ; echo
  a X  Y  Z b

  $ for i in "a${x}c" ; do echo "$i" ; done ; echo
  aX  Y  Zb

Single quotes and double quotes can protect each other from the
shell parser:

  $ echo '"'"$x"'"'
  "X  Y  Z"
  $ echo "'"'"'"$x"'"'"'"
  '"X  Y  Z"'

(It can become as inflationary as Lisp brackets ...)


Have a nice day :)

Thomas

Back to linux.debian.user | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-16 17:30 +0200
  Re: My script almost works but spams the terminal its launched from  if useing dash. Aero Maxx <aero.maxx.d@gmail.com> - 2016-04-16 18:10 +0200
    Re: My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-16 18:50 +0200
      Re: My script almost works but spams the terminal its launched from  if useing dash. Aero Maxx <aero.maxx.d@gmail.com> - 2016-04-16 19:20 +0200
        Re: My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-17 00:50 +0200
        Re: My script almost works but spams the terminal its launched from  if useing dash. Michael Milliman <michael.e.milliman@gmail.com> - 2016-04-17 08:30 +0200
          Re: My script almost works but spams the terminal its launched from if  useing dash. Jeremy Nicoll <jn.ml.dbn.25@letterboxes.org> - 2016-04-17 13:00 +0200
            Re: My script almost works but spams the terminal its launched from if useing dash. "Thomas Schmitt" <scdbackup@gmx.net> - 2016-04-17 13:50 +0200
              Re: My script almost works but spams the terminal its launched from if  useing dash. Jeremy Nicoll <jn.ml.dbn.25@letterboxes.org> - 2016-04-17 15:10 +0200
                Re: My script almost works but spams the terminal its launched from if useing dash. "Thomas Schmitt" <scdbackup@gmx.net> - 2016-04-17 15:30 +0200
                Re: My script almost works but spams the terminal its launched from  if useing dash. Michael Milliman <michael.e.milliman@gmail.com> - 2016-04-17 15:40 +0200
                Re: My script almost works but spams the terminal its launched from if  useing dash. Jeremy Nicoll <jn.ml.dbn.25@letterboxes.org> - 2016-04-17 16:40 +0200
            Re: My script almost works but spams the terminal its launched from  if useing dash. Michael Milliman <michael.e.milliman@gmail.com> - 2016-04-17 15:30 +0200
          Re: My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-17 13:50 +0200
        Re: My script almost works but spams the terminal its launched from  if useing dash. Andrew McGlashan <andrew.mcglashan@affinityvision.com.au> - 2016-04-22 06:30 +0200
          Re: My script almost works but spams the terminal its launched from  if useing dash. Michael Milliman <michael.e.milliman@gmail.com> - 2016-04-22 07:00 +0200
            Re: Re: My script almost works but spams the terminal its launched  from if useing dash. Clive Standbridge <list-user@tgstandbridges.plus.com> - 2016-04-22 11:40 +0200
          Re: My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-22 10:30 +0200
          Re: My script almost works but spams the terminal its launched from  if useing dash. David Wright <deblis@lionunicorn.co.uk> - 2016-04-22 13:10 +0200
  Re: My script almost works but spams the terminal its launched from if useing dash. Sven Joachim <svenjoac@gmx.de> - 2016-04-16 18:50 +0200
    Re: My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-16 19:10 +0200
      Re: My script almost works but spams the terminal its launched from  if useing dash. Linux-Fan <Ma_Sys.ma@web.de> - 2016-04-16 19:30 +0200
      Re: My script almost works but spams the terminal its launched from if useing dash. "Thomas Schmitt" <scdbackup@gmx.net> - 2016-04-16 20:10 +0200
        Re: My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-17 01:10 +0200
          Re: My script almost works but spams the terminal its launched from  if useing dash. David Wright <deblis@lionunicorn.co.uk> - 2016-04-17 04:30 +0200
            Re: My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-17 06:50 +0200
              Re: My script almost works but spams the terminal its launched from  if useing dash. David Wright <deblis@lionunicorn.co.uk> - 2016-04-18 16:00 +0200
                Re: My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-18 20:50 +0200
          Re: My script almost works but spams the terminal its launched from if useing dash. "Thomas Schmitt" <scdbackup@gmx.net> - 2016-04-17 14:10 +0200
          Re: My script almost works but spams the terminal its launched from if useing dash. "Thomas Schmitt" <scdbackup@gmx.net> - 2016-04-17 14:10 +0200
            Re: My script almost works but spams the terminal its launched from if useing dash. Gene Heskett <gheskett@shentel.net> - 2016-04-17 15:20 +0200
              Re: My script almost works but spams the terminal its launched from if useing dash. "Thomas Schmitt" <scdbackup@gmx.net> - 2016-04-17 16:40 +0200

csiph-web