#128 Make error handling quotes within quotes

Known_bugs
closed-invalid
None
2002-08-05
2002-04-20
No

Using the following makefile

all:
@echo "dbl-quotes"
@echo 'single-quotes'
@echo '"dbl-in-single"'
@echo '"single-in-double"'

I ran the following test:

$ cat test.sh
echo
echo Using /bin/make
/bin/make

echo
echo using /var/mingw/bin/make
/var/mingw/bin/make

The output I got was

$ sh test.sh

Using /bin/make
dbl-quotes
single-quotes
"dbl-in-single"
"single-in-double"

using /var/mingw/bin/make
dbl-quotes
single-quotes
\dbl-in-single"
\single-in-double"

Discussion

  • Luke Dunstan

    Luke Dunstan - 2002-04-22

    Logged In: YES
    user_id=30442

    Firstly, your example Makefile has a typo because both the
    dbl-in-single and single-in-dbl lines use double quotes
    within single quotes. Single-in-double quotes work but
    double-in-single don't. The 'make -d' output is:

    CreateProcess(C:\apps\mingw\msys\1.0
    \bin\sh.exe,C:/apps/mingw/msys/1.0/bin/sh.exe -c "echo
    \"dbl-quotes\"",...)
    Putting child 0x003fff58 (all) PID 8918024 on the chain.
    Live child 0x003fff58 (all) PID 8918024
    dbl-quotes
    Reaping winning child 0x003fff58 PID 8918024
    CreateProcess(NULL,sh C:\apps\mingw\msys\1.0\bin\echo
    single-quotes,...)
    Live child 0x003fff58 (all) PID 8918024
    single-quotes
    Reaping winning child 0x003fff58 PID 8918024
    CreateProcess(NULL,sh C:\apps\mingw\msys\1.0\bin\echo \"dbl-
    in-single\",...)
    Live child 0x003fff58 (all) PID 8918024
    \dbl-in-single"
    Reaping winning child 0x003fff58 PID 8918024
    CreateProcess(C:\apps\mingw\msys\1.0
    \bin\sh.exe,C:/apps/mingw/msys/1.0/bin/sh.exe -c "echo
    \"'single-in-double'\"",...)
    Live child 0x003fff58 (all) PID 8919240
    'single-in-double'
    Reaping winning child 0x003fff58 PID 8919240
    Removing child 0x003fff58 PID 8919240 from chain.

    As you can see, the first and last cases are executed
    by "sh -c" (apparently because of the double quotes), so
    the shell built-in echo would be used. The second and third
    cases are executed by "sh /bin/echo" (/bin/echo is a shell
    script). However, the arguments passed to CreateProcess()
    for the incorrect case (the third one) look correct, so is
    this problem because /bin/echo is a shell script? If so,
    perhaps even more special quoting rules need to be added
    to 'make', or instead MSYS could be distributed with an
    echo.exe?

     
  • Robert Konigsberg

    Logged In: YES
    user_id=519873

    Just saw infidel's response. Oops! Hopefully you were able to
    glean the useful information req'd. -Rob

     
  • Earnie Boyd

    Earnie Boyd - 2002-08-05
    • assigned_to: nobody --> earnie
    • status: open --> closed-invalid
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks