Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Especially after edit 2, this really looks to me like a problem with "funny" characters, either nonprinting characters getting mixed in, or normal-looking-but-weird characters like nonbreaking spaces. These can be fairly hard to detect; things can look completely normal in an editor, and even if you view a script with something like <code>cat -v</code> it won't always show funny characters clearly. If you have <code>xxd</code> on your system, it's a really good way to see precisely what's in the file. Here's a quick demo of this type of problem:</p> <pre><code>$ cat -v nbsptest #!/bin/bash -x [ -e /tmp ] &amp;&amp; date [ -e /tmp ] &amp;&amp; date [ -e /tmp ] &amp;&amp; date $ ./nbsptest + '[ -e' /tmp ']' ./nbsptest: line 2: [ -e: command not found + '[' -e '/tmp ]' ./nbsptest: line 3: [: missing `]' + '[' -e /tmp ']' + date Sat Jun 30 10:53:56 PDT 2012 $ xxd nbsptest 0000000: 2321 2f62 696e 2f62 6173 6820 2d78 0a5b #!/bin/bash -x.[ 0000010: c2a0 2d65 202f 746d 7020 5d20 2626 2064 ..-e /tmp ] &amp;&amp; d 0000020: 6174 650a 5b20 2d65 202f 746d 70c2 a05d ate.[ -e /tmp..] 0000030: 2026 2620 6461 7465 0a5b 202d 6520 2f74 &amp;&amp; date.[ -e /t 0000040: 6d70 205d 2026 2620 6461 7465 0a mp ] &amp;&amp; date. </code></pre> <p>The script looks completely normal with <code>cat -v</code> (and <code>more</code>, <code>vi</code>, etc), but the first two commands fail. <code>xxd</code> shows why: the first command has a UTF-8 nonbreaking space between the <code>[</code> and the <code>-e</code> (this shows as c2a0 in the hex listing, <code>[..-e</code> in the text listing) and the second command has a nonbreaking space between <code>/tmp</code> and <code>]</code> (<code>/tmp..]</code> in the text listing).</p> <p>The <code>-x</code> display (I used <code>bash -x</code> to invoke it, you can also use <code>set -x</code> as @CodeGnome suggested) also gives a hint about what's going on. For the first command, it listed it as <code>'[ -e' /tmp ']'</code> -- note the quotes around <code>[ -e</code>, which indicates that the shell is treating that all as one "word", which means it doesn't think that's a space in the middle of it. Similarly, the second command is displayed as <code>'[' -e '/tmp ]'</code> with the quotes indicating that it thinks <code>/tmp ]</code> is all one "word".</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload