Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux installation fails: bash scripts have literal \n instead of newlines #979

Closed
tve opened this issue Dec 13, 2022 · 9 comments
Closed
Labels
fixed - please verify Issue has been fixed. Please verify and close.

Comments

@tve
Copy link
Contributor

tve commented Dec 13, 2022

Build environment: Linux arch

Description
The shell scripts built have literal \n's in them

Steps to Reproduce

  1. Git clone repo
  2. cd build/makefiles/lin
  3. make
make -f /home/sw/moddable/moddable/xs/makefiles/lin/xsc.mk                           
make[1]: Entering directory '/home/sw/moddable/moddable/build/makefiles/lin'         
# xsc debug : cc xsBigInt.c                                                          
# xsc debug : cc xsCode.c                                                            
...
# tools debug : mcconfig
...
# tools debug : mcrun
make[1]: Leaving directory '/home/sw/moddable/moddable/build/makefiles/lin'
/home/sw/moddable/moddable/build/bin/lin/debug/mcconfig -d -m -p x-lin /home/sw/moddable/moddable/tools/xsbug/manifest.json
make: /home/sw/moddable/moddable/build/bin/lin/debug/mcconfig: No such file or directory
make: *** [makefile:42: debug] Error 127
  1. cat /home/sw/moddable/moddable/build/bin/lin/debug/mcconfig
#!/bin/bash\nDIR=$(cd "$(dirname "$BASH_SOURCE")"; cd -P "$(dirname "$(readlink "$BASH_SOURCE" || echo .)")"; pwd)\n$DIR/tools mcconfig "$@"
  1. Notice that this is one line with embedded literal \n's, that ain't gonna work...
@tve
Copy link
Contributor Author

tve commented Dec 13, 2022

I'm using fish shell, man echo says:

       -E     Disable interpretation of backslash escapes (default).                 
       -e     Enable interpretation of backslash escapes.                            

using bash I get the same:

       -e     enable interpretation of backslash escapes
       -E     disable interpretation of backslash escapes (default)

puzzled how this works for you...

@andycarle
Copy link
Member

Interesting... This is what I get in zsh on Ubuntu:

 acarle@ANDY-SURFACE ~/Projects/moddable cat ./build/bin/lin/debug/mcconfig
#!/bin/bash
DIR=$(cd "$(dirname "$BASH_SOURCE")"; cd -P "$(dirname "$(readlink "$BASH_SOURCE" || echo .)")"; pwd)
$DIR/tools mcconfig "$@"

@andycarle
Copy link
Member

A few thoughts.

  1. As you probably noted, these scripts are generated in a Makefile (build\makefiles\lin\tools.mk).
  2. I believe make uses /bin/sh by default.
  3. sh does not have a -e option and always interprets backslash escapes.

Perhaps you either have /bin/sh mapped so something else (e.g. fish) or you have over ridden the default shell for make?

@tve
Copy link
Contributor Author

tve commented Dec 13, 2022

It works on ubuntu... (Although I have a headless system and didn't appreciate having 177 packages installed for libgtk-3-dev)
On Arch /bin/sh seems to have been bash for a long time
On Ubuntu /bin/sh is dash
I would suggest that adding -e to the echo statements is more portable... Don't you need that on macos as well? I have some vague (painful) memories of deja-vu...
I installed dash and ran make SHELL=/usr/bin/dash and that seems to have completed the build.
Thanks for the prompt replies!

@andycarle
Copy link
Member

You're right, dash is what is being invoked on my system.

This from dash's echo seems problematic to the approach of always adding the -e:

$ echo -e "Testing\n123"
-e Testing
123

@tve
Copy link
Contributor Author

tve commented Dec 13, 2022

then maybe set SHELL=dash in the makefile?

It looks like what I built compiles the helloworld fine, but I'm not sure it ran fine. When I ran mcconfig -d -m -p lin xsbug immediately displayed a stack trace on readPreferenceString and in its console shows:
/home/sw/moddable/moddable/modules/piu/PC/lin/piuFiles.c (222) # Break: readPreferenceString: No such file or directory!
Dunno whether I skipped some instructions or whether instructions are incomplete...

@andycarle
Copy link
Member

May be another difference with arch — we definitely do most of our Linux testing on Ubuntu. I recommend opening a new issue for that one and I'll get the right person pointed to it.

@andycarle
Copy link
Member

I think setting SHELL = /bin/dash in tools.mk is a reasonable compromise here. On the odd system that doesn't have /bin/dash that should at least fail fast.

I'll get that change in.

mkellner pushed a commit that referenced this issue Dec 30, 2022
…nterpretation on systems with non-dash /bin/sh mappings (#979)
@phoddie phoddie added the fixed - please verify Issue has been fixed. Please verify and close. label Jan 10, 2023
@phoddie phoddie closed this as completed Jan 10, 2023
@tve
Copy link
Contributor Author

tve commented Jan 23, 2023

Works now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed - please verify Issue has been fixed. Please verify and close.
Projects
None yet
Development

No branches or pull requests

3 participants