Ticket #35232

eval "return" does not return from function

Date d'ouverture: 2015-06-12 10:02 Dernière mise à jour: 2015-07-05 23:56

Rapporteur:
Propriétaire:
Type:
État:
Atteints
Composant:
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

When executing a function, and "return" is encountered within an "eval" statement, yash does not return from the function; instead, it only stops executing the "eval" and continues the function after it. Every other shell (bash, *ksh*, zsh, (d)ash, etc.) returns from the function.

testfn() {
    echo 1
    eval "echo 2; return; echo 3"
    echo 4
}
testfn

Actual output:

1
2
4

Expected output:

1
2

Example of real-life use case: unset some temporary variables, then return with the exit code of the command preceding the 'eval'. Using 'eval' removes the need to store the exit status in a variable. This bug makes it harder to do this in yash -- eval does exit with the saved status, but then in yash, another "return" is needed after the eval.

eval "unset -v temp1 temp2; return $?"

Ticket History (3/4 Histories)

2015-06-12 10:02 Updated by: mcdutchie
  • New Ticket "eval "return" does not return from function" created
2015-06-12 22:01 Updated by: mcdutchie
  • Composant Update from (Aucun) to shell-builtin
  • Propriétaire Update from (Aucun) to magicant
2015-06-12 22:24 Updated by: magicant
Commentaire

Hmm. The cancel_return call at the end of the parse_and_exec function is not doing the right thing.

2015-07-05 23:56 Updated by: magicant
  • Résolution Update from Aucun to Fixed
  • État Update from Ouvert to Atteints
  • Ticket Close date is changed to 2015-07-05 23:56
Commentaire

Fixed in r3316

Thanks for reporting!

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