Ticket #43467

'local var' is available in POSIX mode

Eröffnet am: 2021-12-23 16:11 Letztes Update: 2022-09-28 22:43

Auswertung:
(Anonym)
Verantwortlicher:
(Keine)
Typ:
Status:
Geschlossen
Komponente:
(Keine)
Meilenstein:
(Keine)
Priorität:
5 - Mittel
Schweregrad:
5 - Mittel
Lösung:
Gefixt
Datei:
Keine
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

Details

sample:

  1. func() {
  2. local a=123
  3. echo $a
  4. }
  5. func

command used to reproduce the bug:

yash -o posixlycorrect path/to/sample/script

output:

123 (no error)

expected behavior:

local isn't posix and yash should exit with fatal error

Ticket-Verlauf (3/9 Historien)

2021-12-23 16:11 Aktualisiert von: None
  • New Ticket "'local var' is available in POSIX mode" created
2021-12-26 12:01 Aktualisiert von: magicant
Kommentar

Affected built-ins:

  • bindkey
  • complete
  • dirs
  • disown
  • help
  • history
  • local
  • popd
  • pushd
  • suspend
  • typeset
2022-06-07 18:59 Aktualisiert von: dumblob
Kommentar

I second this request to fix this bug with local.

2022-08-23 22:50 Aktualisiert von: magicant
Kommentar

magicant への返信

Affected built-ins: bindkey, complete, dirs, disown, help, history, local, popd, pushd, suspend, typeset

These built-ins have been semi-special built-ins since #36741. POSIX defines the behavior of them unspecified, so the current implementation is not a bug.

However, rejecting use of these non-portable built-ins might be helpful if you are checking portability of a script you wrote.

Note that the correct expected behavior for an unknown command is to return a non-zero exit status with a message. POSIX does not require the shell to exit on this kind of error, unless you set the errexit option.

2022-09-04 00:52 Aktualisiert von: None
Kommentar

I would call it a bug since yash states that its POSIX mode supposed to be more strict, i.e it supposed to prohibit non-posix extensions at least. What I see right now is that yash isn't strict at all, hence this bug.

2022-09-04 11:53 Aktualisiert von: magicant
Kommentar

The POSIXly-correct mode makes the shell literally POSIXly correct, but it does not necessarily disable all non-portable features. Command line completion is another example of a non-portable feature that can be used in the POSIX mode.

Disabling non-portable built-ins would be okay, but that is merely one of many possible implementation-defined behaviors.

2022-09-04 15:25 Aktualisiert von: None
Kommentar

OK. Could you clarify what does "featuring more strict POSIX compliance than those of other shells" mean? How yash is "more strict" than those shells if it allows using non-posix extensions in POSIXly-correct mode? Sorry if it's offtopic

2022-09-04 16:20 Aktualisiert von: magicant
Kommentar

POSIX defines what shells must do, and yash indeed does so. That is what compliance is all about. Historically there were some other shells that claimed they were POSIX-compliant and still did not do things POSIX required. Yash is not like those shells.

2022-09-28 22:43 Aktualisiert von: magicant
  • Status Update from Offen to Geschlossen
  • Lösung Update from Keine to Gefixt
Kommentar

Done in r4207

Dateianhangliste

Keine Anhänge

Bearbeiten

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Anmelden