[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #56764] Different behavior of printf command executed from Makefile
From: |
Martin Dorey |
Subject: |
[bug #56764] Different behavior of printf command executed from Makefile and from shell. |
Date: |
Tue, 20 Aug 2019 01:49:17 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36 |
Follow-up Comment #3, bug #56764 (project make):
[comment #2 comment #2:]
> When make invokes printf it's assuming a POSIX shell, and running the
/usr/bin/printf executable not the bash builtin.
Look ma, no /usr/bin/printf:
mad@shuttle:~/tmp/make-56764$ strace -f make 2>&1 | grep exec
execve("/usr/bin/make", ["make"], [/* 42 vars */]) = 0
[pid 31739] execve("/bin/sh", ["/bin/sh", "-c", "printf '\\x00\\x00\\x8f\\x60'
> gene"...], [/* 45 vars */] <unfinished ...>
[pid 31739] <... execve resumed> ) = 0
mad@shuttle:~/tmp/make-56764$ hexdump -C generated_file.bin
00000000 5c 78 30 30 5c 78 30 30 5c 78 38 66 5c 78 36 30
|\x00\x00\x8f\x60|
00000010
mad@shuttle:~/tmp/make-56764$
That's using exactly the OP's makefile. If I'd have been posting the bug
report, I'd have written the makefile on one line, to avoid problems with tabs
in emails:
mad@shuttle:~/tmp/make-56764$ cat Makefile.martind
generated_file: ; @printf '\x00\x00\x8f\x60'
mad@shuttle:~/tmp/make-56764$ make -f Makefile.martind | hexdump -C
00000000 00 00 8f 60 |...`|
00000004
mad@shuttle:~/tmp/make-56764$
Oh dear, the problem's gone away, but what's this:
mad@shuttle:~/tmp/make-56764$ strace -f make -f Makefile.martind 2>&1 | grep
exec
execve("/usr/bin/make", ["make", "-f", "Makefile.martind"], [/* 42 vars */]) =
0
[pid 31938] execve("/usr/local/bin/printf", ["printf",
"\\x00\\x00\\x8f\\x60"], [/* 45 vars */]) = -1 ENOENT (No such file or
directory)
[pid 31938] execve("/usr/bin/printf", ["printf", "\\x00\\x00\\x8f\\x60"], [/*
45 vars */]) = 0
mad@shuttle:~/tmp/make-56764$
Now it's executed /usr/bin/printf, as Paul suggested it would, but, on this
computer, Debian Stretch's coreutils' /usr/bin/printf supports these
non-standard escapes. I think it's the OP's > which stops make from executing
/usr/bin/printf directly.
I have no dispute with anything else Paul wrote. Ugh, octal, I wish we could
let the 1970s go.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?56764>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/