emersion / emersion/mrsh

Potentially inconsistent wordsplitting behaviour on export assignment

Open
#150 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
531
Forks
40
PR merge metrics
No merged PRs in 30d

Description

According to [wooledge](https://mywiki.wooledge.org/BashPitfalls#local_var.3D.24.28cmd.29) it is possible that a shell may induce wordsplitting on export assignment if the expansion isn't properly quoted (the example is for local but mentions the case is the same for export). The wiki claims dash is susceptible to this but I did not encounter the behaviour:

```sh
#!/bin/sh --
var='contains spaces'
export ENVAR=$var
printf '[%s]\n' "$ENVAR"
```

```sh
% for shell in bash dash sh zsh mksh mrsh; do printf '%s: ' "$shell"; "$shell" foo.sh; done
bash: [contains spaces]
dash: [contains spaces]
sh: [contains spaces]
zsh: [contains spaces]
mksh: [contains spaces]
mrsh: [contains]
```

Of the shells I have, mrsh is the only one which exhibits the behaviour wooledge suggests is possible but I'm unsure if this is a bug or merely a different interpretation of POSIX.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.