Closed kiwiroy closed 6 years ago
#!/bin/bash
has been changed to #!/bin/sh
(and the code updated to run well with busybox sh and dash) some time ago to allow builds on Linux hosts that have no bash installed, and/or prefer not to use bash for this purpose. I'm pretty sure there are users who depend on this, too. Switching back to bash is not a good idea at this point.
If your build infrastructure allows it, patching that after unpacking perl-cross may be a better solution. Either sh -> bash, or maybe try to replace echo with printf if Darwin sh supports printf.
No objections to readelf
changes if that's enough to get it working on Darwin.
If you're ok with that, I'd apply the readelf parts of the patch only.
@arsv sorry I wasn't aware /bin/sh
was a fixed requirement. f3f08f6 switches to use env
to achieve the same affect (untested on busybox).
Yeah but that would be a really weird thing to do in Linux.
And dependency on env
isn't really any better than dependency on echo -n
.
Could you please check if the following fragment works correctly in Darwin? https://gist.github.com/arsv/18e6c930897275b378c427a2d6a81522
That fragment works as expected.
Bash is not the problem, echo -n
works just fine in bash. Pretty much anything would work in bash, including printf. The case
should be between Darwin)
and *)
everything else, it's Darwin sh that needs special treatment for its lack of echo -n
.
By the way, does printf
work in Darwin shell?
When sh
is bash
or is linked to bash
it behaves like sh
and or if certain shopt
settings are set. There may be a version 3 vs 4 bash
difference also, I don't have a Linux with bash v3 to confirm though. printf
is available on Darwin.
Please take a look at https://github.com/arsv/perl-cross/tree/darwin and try it on Darwin is possible. I tweaked you commit a bit, if you're ok with that I'd merge it.
Only mstart
actually needs no-newline printing.
The other cases used echo -n > $file
to truncate $file
.
@arsv ab8d05c is great. Thanks.
Ok, thanks, changes merged.
overview
/bin/bash
in shebang to allowecho -n
readelf -s
->readelf --syms
to allowgobjdump
as substitute (see wrapper below)gobjdump
outputmotivation
When using
/bin/sh
,echo
does not support the-n
flag which results in it being printed along with the string with undesired effects.readelf
needs to be replaced withgobjdump
on Mac, but this doesn't support-s
, but does allow--syms
asreadelf
does. (readelf
withgcc
6.4, macports barfs with "Error: Not an ELF file - it has the wrong magic bytes at the start" fortry.o
)wrapper
I have a small wrapper called
readelf
in$PATH
thus:And similar for
objdump
->gobjdump
andsed
->gsed
.