Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Please read the section titled QUOTING in bash(1) (<code>man bash</code>).</p> <p>In your first example,</p> <pre><code>echo "C:\Users\Ted\Documents\Unix\Scripts" | xargs echo </code></pre> <p>the shell interprets (and then removes) backslashes within double quotes, so the first <code>echo</code> command only sees the string <code>C:UsersTedDocumentsUnixScripts</code>.</p> <p>In your second example,</p> <pre><code>echo 'C:\Users\Ted\Documents\Unix\Scripts' | xargs echo </code></pre> <p>the single quotes correctly protect the backslashes, as you can see by running just the first <code>echo</code> command, without the <code>| xargs echo</code>.</p> <p>In all of your remaining examples,</p> <pre><code>cyg0 C:\Users\Ted\Music\Enigma cyg1 C:\Users\Ted\Music\Enigma ... </code></pre> <p>since the argument (<code>C:\Users\Ted\Music\Enigma</code>) is unquoted, once again the shell interprets and removes the backslashes before the command (<code>cyg0</code>, <code>cyg1</code>, ...) ever sees them. And...</p> <blockquote> <p>I want to be able to type C:\Users\Ted\Music\Enigma without quotes.</p> </blockquote> <p>Sorry, it can't be done. If you don't put the backslashes in single quotes, the shell will interpret each one as a quoting character for the character that follows it, then remove the backslash.</p> <p>You have a few options:</p> <ol> <li><p>Use single quotes on the command line, to protect the backslashes:</p> <pre><code>cyg4 'C:\Users\Ted\Music\Enigma' </code></pre></li> <li><p>Quote each backslash character separately, by doubling it, e.g.</p> <pre><code>cyg4 C:\\Users\\Ted\\Music\\Enigma </code></pre></li> <li><p>Use forward slashes instead:</p> <pre><code>cyg4 C:/Users/Ted/Music/Enigma </code></pre></li> </ol> <p>Option 3 could really be your best solution. Unfortunately the backslash character is just a very special character for all Unix shells, and this causes a lot of quoting hassles when dealing with DOS/Windows paths. But what's not widely known is that DOS/Windows is also perfectly happy to use the forward slash (<code>/</code>) as its path separator. Try it.</p> <p>Note: Of your several cyg* functions, only cyg1 and cyg4 are correct. The others use incorrect quoting. cyg1 is only useful with one argument since it joins all of the arguments together into one quoted string, while cyg4 can accept and pass on multiple arguments to cygpath. However, since cyg4 only passes on its quoted arguments, it doesn't add any value; it's really no different from just e.g.</p> <pre><code>cygpath C:/Users/Ted/Music/Enigma </code></pre> <p>Good luck.</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.
    3. VO
      singulars
      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