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

Syntax error: "(" unexpected (expecting "fi") #15

Open
ulysses4ever opened this issue Aug 18, 2016 · 6 comments
Open

Syntax error: "(" unexpected (expecting "fi") #15

ulysses4ever opened this issue Aug 18, 2016 · 6 comments

Comments

@ulysses4ever
Copy link

I downloaded the script, run it on my Ubuntu 16.04 laptop and get

$ with ls
/home/ulysses/bin/with: 12: /home/ulysses/bin/with: Syntax error: "(" unexpected (expecting "fi")
@eush77
Copy link

eush77 commented Aug 18, 2016

Same error for me under Dash (which is what /bin/sh is sym-linked to on my system). Runs ok under Bash though.

@ulysses4ever
Copy link
Author

ulysses4ever commented Aug 18, 2016

I tried it (and got above mentioned error) in gnome-terminal.

@ulysses4ever
Copy link
Author

ulysses4ever commented Aug 18, 2016

Oh, I see: I also have /bin/sh synlinked to dash. I just changed the script to call bash. Though it would be nice if authors accounted this somehow.

@eush77
Copy link

eush77 commented Aug 18, 2016

Yeah, the workaround is to change the interpreter to Bash. Although it was changed the other way in 61d059d so it is probably in the author's intentions to make it run under any POSIX shell.

Either way, I don't think this issue should be closed right now.

@mchav
Copy link
Owner

mchav commented Aug 19, 2016

Yes @eush77 I'd like it to run under any Posix shell. We'll keep the issue open. If anyone has any insights on how to run it on dash please let me know.

@eush77
Copy link

eush77 commented Aug 20, 2016

I ran shellcheck on this script with the first line changed to #!/bin/sh and it found several Bash-specific features used by the code:

  • arrays;
  • here-strings;
  • read -e (readline mode);
  • escaped string literals ($'\n');
  • declare and type builtins.

And it somehow missed this:

  • substring expansion (${parameter:offset:length})— not specified by POSIX.

Overall, it seems highly non-trivial to make with run under any POSIX shell, which lack some crucial features that are otherwise supported by Bash (how can we work around missing read -e?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants