1 |
Am 20.06.2011 12:39, schrieb Adam Carter: |
2 |
>>> /bin/sh is a symlink to bash. |
3 |
>> |
4 |
>> Which runs as sh when run from the symlink. |
5 |
> |
6 |
> I dont understand. "runs as" usually means "runs under the user |
7 |
> context" to me - are you saying bash has an sh compatibility mode? |
8 |
> |
9 |
|
10 |
Yes, that's exactly what he wants to say. |
11 |
Interestingly, that mode still supports most bash-only features like |
12 |
arrays. I guess they can do this because it doesn't change the semantic |
13 |
of old Bourne shell code. It just makes some formerly invalid syntax valid. |
14 |
|
15 |
/bin/sh -c -c 'array=( sh bash ); echo I am a ${array[1]}' 2>/dev/null |
16 |
|| echo I am a sh |
17 |
> I am a bash |
18 |
|
19 |
Other drop-in replacements for /bin/sh like dash are less forgiving: |
20 |
|
21 |
/bin/dash -c -c 'array=( sh bash ); echo I am a ${array[1]}' 2>/dev/null |
22 |
|| echo I am a sh |
23 |
> I am a sh |