[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[POSIX] `a='a b'; export a=$a; echo $a` gives `a b` instead of `a`
From: |
Mingye Wang (Arthur2e5) |
Subject: |
[POSIX] `a='a b'; export a=$a; echo $a` gives `a b` instead of `a` |
Date: |
Sat, 5 Dec 2015 18:57:28 -0500 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
Bash Version: 4.3
Patch Level: 42
Release Status: Release
Description:
According to [POSIX.1], `export` is special builtin *command*.
Therefore as a command, in `a='a b'; export a=$a; echo $a`, `$a` should
get split into words `a` and `b`.
However, `bash` takes this as `export 'a=a b'` and gives un-POSIX
results. To make sure this is not a `bash` extension since this is
actually a common headache for new users and `bash` may try to extend
its syntax here, I tried `bash --posix`, but it exhibits the same
non-POSIX behavior.
Repeat-By:
Just run this in `bash`, `bash --posix` and `dash`:
set -xv
a='a b'
export a=$a
echo $a
[POSIX.1]:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#export
--
Regards,
Arthur2e5
signature.asc
Description: OpenPGP digital signature
- [POSIX] `a='a b'; export a=$a; echo $a` gives `a b` instead of `a`,
Mingye Wang (Arthur2e5) <=