FS#43661 - [mkinitcpio] systemd hook: Please use less arcane syntax, fix (possible) syntax error
Attached to Project:
Arch Linux
Opened by Alain Kalker (ackalker) - Sunday, 01 February 2015, 17:24 GMT
Last edited by Dave Reisner (falconindy) - Sunday, 01 February 2015, 22:49 GMT
Opened by Alain Kalker (ackalker) - Sunday, 01 February 2015, 17:24 GMT
Last edited by Dave Reisner (falconindy) - Sunday, 01 February 2015, 22:49 GMT
|
Details
Description:
Visiting /usr/lib/initcpio/install/systemd (or the equivalent file in the package source) in Emacs greatly confuses the syntax highlighting because of lines like: 4: local len=${#1} quotes=$'[\'"]' str=${!1} Please consider changing this to the more readable and machine-parsable: 4: local len=${#1} quotes=[\'\"] str=${!1} After this change, Emacs' syntax highlighting no longer treats the rest of the file as an unterminated string. Similarly, on this line: 28: [[ -z $rule || $rule = @(+([[:space:]])|#*) ]] && continue Emacs syntax highlighting treats this part as a comment: #*) ]] && continue Please consider changing this line to: 28: [[ -z $rule || $rule = "@(+([[:space:]])|#*)" ]] && continue if only to make syntax highlighters happy. Finally, on line 33, there appears to be a syntax error (found by Emacs Flycheck): /bin/bash: line 33: syntax error near unexpected token `(' /bin/bash: line 33: ` RUN@({program}|+)|IMPORT{program}|ENV{REMOVE_CMD})' I'm guessing that this wasn't caught before is that hooks are sourced, not executed, by mkinitcpio. I know that there are subtle differences in how sourced and executed scripts are handled, but I don't think it is wise to rely on those for correct operation, in paticular if they limit the use of tools like syntax checkers. Additional info: * package version(s) mkinitcpio 18-2 * config and/or log files etc. Steps to reproduce: $ echo $SHELL /bin/bash $ bash /usr/lib/initcpio/install/systemd bash /usr/lib/initcpio/install/systemd /usr/lib/initcpio/install/systemd: line 33: syntax error near unexpected token `(' /usr/lib/initcpio/install/systemd: line 33: ` RUN@({program}|+)|IMPORT{program}|ENV{REMOVE_CMD})' $ echo $? 2 $ . /usr/lib/initcpio/install/systemd $ echo $? 0 (or use Emacs with Flycheck) |
This task depends upon
Closed by Dave Reisner (falconindy)
Sunday, 01 February 2015, 22:49 GMT
Reason for closing: Not a bug
Additional comments about closing: Please work with your editor's upstream to improve the syntax highlighting.
Sunday, 01 February 2015, 22:49 GMT
Reason for closing: Not a bug
Additional comments about closing: Please work with your editor's upstream to improve the syntax highlighting.
Apparently, `bash -n` doesn't act on `shopt -s extglob` inside scripts, so that doesn't help either.
33: RUN@({program}|+)|IMPORT{program}|ENV{REMOVE_CMD})
to:
33: RUN{program}|RUN+|IMPORT{program}|ENV{REMOVE_CMD})
This resolves the "syntax error" in Flycheck and `bash -n ...`, is slightly better readable for anyone not familiar with extglob extended pattern matching operators, and has zero cost in number of bytes.
> 28: [[ -z $rule || $rule = "@(+([[:space:]])|#*)" ]] && continue
This isn't even functionally equivalent. Quoting the glob makes it no longer a glob.
> Apparently, `bash -n` doesn't act on `shopt -s extglob` inside scripts, so that doesn't help either.
Sure, bash -n won't execute commands (which includes shopts). Use: bash -n -O extglob ...
Please fix your editor, there's nothing "arcane" about the syntax used here. Rather, it's all well-documented shell constructs.
Sorry about the first one, I didn't realize that it was an extended glob pattern until reading on, see my previous comment.
> Please fix your editor, there's nothing "arcane" about the syntax used here.
Vim indeed has no trouble with it.