Ticket #43467

'local var' is available in POSIX mode

Date d'ouverture: 2021-12-23 16:11 Dernière mise à jour: 2022-09-28 22:43

Rapporteur:
(Anonyme)
Propriétaire:
(Aucun)
Type:
État:
Atteints
Composant:
(Aucun)
Jalon:
(Aucun)
Priorité:
5 - moyen
Sévérité:
5 - moyen
Résolution:
Fixed
Fichier:
Aucun
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

Détails

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 History (3/9 Histories)

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

Affected built-ins:

  • bindkey
  • complete
  • dirs
  • disown
  • help
  • history
  • local
  • popd
  • pushd
  • suspend
  • typeset
2022-06-07 18:59 Updated by: dumblob
Commentaire

I second this request to fix this bug with local.

2022-08-23 22:50 Updated by: magicant
Commentaire

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 Updated by: None
Commentaire

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 Updated by: magicant
Commentaire

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 Updated by: None
Commentaire

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 Updated by: magicant
Commentaire

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 Updated by: magicant
  • État Update from Ouvert to Atteints
  • Résolution Update from Aucun to Fixed
Commentaire

Done in r4207

Attachment File List

No attachments

Modifier

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