Re: [ksh] Warning: pipe symbol within ${} should be quoted?

Liste des GroupesRevenir à cu shell 
Sujet : Re: [ksh] Warning: pipe symbol within ${} should be quoted?
De : apple.universe (at) *nospam* posteo.net (Eric Pozharski)
Groupes : comp.unix.shell
Date : 31. May 2025, 20:15:08
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrn103ml9s.8do.apple.universe@freight.zombinet>
References : 1 2 3
User-Agent : slrn/1.0.3 (Linux)
with <101dbii$n5nn$1@dont-email.me> Janis Papanagnou wrote:
On 30.05.2025 21:52, Martijn Dekker wrote:
Op 08-05-2025 om 00:00 schreef Janis Papanagnou:

With syntax-check ('ksh -n') I get a warning in Ksh for this expression
   "${pipe#* | }"
concerning the pipe symbol. (Bash and Zsh don't complain.)
But bash and zsh don't offer linter functionality with -n at all, do they?
I don't know what they internally do when '-n' is provided, but the
man page (e.g. "man bash") says for the 'set' command (-n/-o noexec)
>
    -n   Read commands but do not execute them. This may be used
         to check a shell script for syntax errors. This is ignored
         by interactive shells.
>
which appears to be the same as what's written in the Ksh man page
(and in POSIX), and I suppose a similar thing valid for Zsh.

That is correct:

    EXEC (+n, ksh: +n) <D>
Do execute commands.  Without this option, commands are read and
checked for syntax errors, but not executed.  This option cannot
be turned off in an interactive shell, except when `-n' is
supplied to the shell at startup.

Yes, reading zsh.info requires some amount of mental gymnastics (or
parkour, if I may);  and sometimes hurts.

Also, dash(1):

    -n noexec    If not interactive, read commands but do not execute
them.  This is useful for checking the syntax of shell
scripts.

Also, surprise-surprise, sh of busybox (which doesn't do manuals like at
all, because manuals are for suckers(?)) with file like this:

echo foo
echo "bar

complains about "unterminated quted string" and doesn't output anything
with '-n' present;  and outputs 'foo' without it and then complains.

*CUT* [ 71 lines   3 levels deep]

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom

Date Sujet#  Auteur
8 May 25 * [ksh] Warning: pipe symbol within ${} should be quoted?4Janis Papanagnou
30 May20:52 `* Re: [ksh] Warning: pipe symbol within ${} should be quoted?3Martijn Dekker
30 May23:30  `* Re: [ksh] Warning: pipe symbol within ${} should be quoted?2Janis Papanagnou
31 May20:15   `- Re: [ksh] Warning: pipe symbol within ${} should be quoted?1Eric Pozharski

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal