Can I view Bash POSIX extensions?
Clash Royale CLAN TAG#URR8PPP
up vote
-2
down vote
favorite
I'm reading about the bash
shell and I've read from many sources that to make bash
POSIX compliant it needs "extensions". Which sounds to me like something I should be able to load or unload into bash. I've tried googling the subject but can't seem to find any detail about this subject. What little I can find basically says nothing more than "Bash needs extensions".
Is there a way I can view the extensions Bash is loading? Load or unload them? Configure them differently?
linux bash posix
add a comment |Â
up vote
-2
down vote
favorite
I'm reading about the bash
shell and I've read from many sources that to make bash
POSIX compliant it needs "extensions". Which sounds to me like something I should be able to load or unload into bash. I've tried googling the subject but can't seem to find any detail about this subject. What little I can find basically says nothing more than "Bash needs extensions".
Is there a way I can view the extensions Bash is loading? Load or unload them? Configure them differently?
linux bash posix
This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
â ilkkachu
Jan 13 at 20:09
add a comment |Â
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I'm reading about the bash
shell and I've read from many sources that to make bash
POSIX compliant it needs "extensions". Which sounds to me like something I should be able to load or unload into bash. I've tried googling the subject but can't seem to find any detail about this subject. What little I can find basically says nothing more than "Bash needs extensions".
Is there a way I can view the extensions Bash is loading? Load or unload them? Configure them differently?
linux bash posix
I'm reading about the bash
shell and I've read from many sources that to make bash
POSIX compliant it needs "extensions". Which sounds to me like something I should be able to load or unload into bash. I've tried googling the subject but can't seem to find any detail about this subject. What little I can find basically says nothing more than "Bash needs extensions".
Is there a way I can view the extensions Bash is loading? Load or unload them? Configure them differently?
linux bash posix
edited Jan 13 at 20:07
jimmij
28.9k867100
28.9k867100
asked Jan 13 at 19:38
Bodisha
232
232
This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
â ilkkachu
Jan 13 at 20:09
add a comment |Â
This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
â ilkkachu
Jan 13 at 20:09
This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
â ilkkachu
Jan 13 at 20:09
This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
â ilkkachu
Jan 13 at 20:09
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.
Those extensions include things like the [[
test syntax, a,b,c
brace expansion, variable indirection with $!x
, process substitution with <(...)
, and history expansion with !
. The extensions are the non-POSIX parts of Bash, in this sense.
They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash
if, for example, it uses the !
character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:
foo() ... ;
x=1 foo
echo $x
In POSIX sh
, that should output "1
", but run with bash
the assignment to x
doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.
Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time
command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time
executable runs instead in some cases:
$ time --help
bash: --help: command not found
$ set -o posix
$ time --help
Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]
There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[
and $!x
, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.
There are other shells, notably dash
, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.
add a comment |Â
up vote
0
down vote
There are three different ways to force bash
to be POSIX compliant.
- Start
bash
with--posix
option - Set option posix while bash is already running:
set -o posix
Use environment variable
POSIXLY_CORRECT
:
If this variable is in the environment when bash starts, the shell
enters posix mode before reading the startup files, as if the--posix
invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the commandset -o posix
had been executed.
Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.
Those extensions include things like the [[
test syntax, a,b,c
brace expansion, variable indirection with $!x
, process substitution with <(...)
, and history expansion with !
. The extensions are the non-POSIX parts of Bash, in this sense.
They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash
if, for example, it uses the !
character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:
foo() ... ;
x=1 foo
echo $x
In POSIX sh
, that should output "1
", but run with bash
the assignment to x
doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.
Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time
command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time
executable runs instead in some cases:
$ time --help
bash: --help: command not found
$ set -o posix
$ time --help
Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]
There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[
and $!x
, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.
There are other shells, notably dash
, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.
add a comment |Â
up vote
4
down vote
Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.
Those extensions include things like the [[
test syntax, a,b,c
brace expansion, variable indirection with $!x
, process substitution with <(...)
, and history expansion with !
. The extensions are the non-POSIX parts of Bash, in this sense.
They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash
if, for example, it uses the !
character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:
foo() ... ;
x=1 foo
echo $x
In POSIX sh
, that should output "1
", but run with bash
the assignment to x
doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.
Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time
command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time
executable runs instead in some cases:
$ time --help
bash: --help: command not found
$ set -o posix
$ time --help
Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]
There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[
and $!x
, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.
There are other shells, notably dash
, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.
add a comment |Â
up vote
4
down vote
up vote
4
down vote
Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.
Those extensions include things like the [[
test syntax, a,b,c
brace expansion, variable indirection with $!x
, process substitution with <(...)
, and history expansion with !
. The extensions are the non-POSIX parts of Bash, in this sense.
They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash
if, for example, it uses the !
character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:
foo() ... ;
x=1 foo
echo $x
In POSIX sh
, that should output "1
", but run with bash
the assignment to x
doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.
Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time
command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time
executable runs instead in some cases:
$ time --help
bash: --help: command not found
$ set -o posix
$ time --help
Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]
There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[
and $!x
, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.
There are other shells, notably dash
, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.
Bash has many features and behaviours beyond or contrary to what POSIX specifies. These are sometimes described as extensions to the standard; they are not loadable extensions in the sense found in some applications.
Those extensions include things like the [[
test syntax, a,b,c
brace expansion, variable indirection with $!x
, process substitution with <(...)
, and history expansion with !
. The extensions are the non-POSIX parts of Bash, in this sense.
They also include various changes to the behaviour of commands and syntax. A POSIX script can behave differently when run with bash
if, for example, it uses the !
character that will instead be interpreted as an attempted history expansion, or it relies on pre-command assignment statements sticking around after the command:
foo() ... ;
x=1 foo
echo $x
In POSIX sh
, that should output "1
", but run with bash
the assignment to x
doesn't persist after the command, in order to avoid cluttering the variable namespace in the common case.
Bash has a POSIX mode that alters its behaviour to be more POSIX-like in the situations where a reasonable POSIX script would behave differently. One example of that other than the above is Bash's (very useful) extension of the time
command to handle pipelines, which is by necessity built in. In POSIX mode, the system's time
executable runs instead in some cases:
$ time --help
bash: --help: command not found
$ set -o posix
$ time --help
Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]
There is a list of currently-56 behavioural changes in POSIX mode in the documentation. Most other extensions, like [[
and $!x
, still work even in POSIX mode, though process substitution doesn't. For the most part, only differences that might break a reasonable POSIX script are reverted. This is really the only "disabling" of the extensions that exists. In POSIX mode, a POSIX script ought to behave as expected (though it's still easily possible to construct cases where it doesn't). Even in POSIX mode, a Bash script can use some non-POSIX features provided by the shell that don't directly conflict with the standard.
There are other shells, notably dash
, that attempt a more minimal POSIX compliance. The major way of eliminating non-POSIX extensions is to switch to using one of those shells.
answered Jan 13 at 20:05
Michael Homer
42.5k6108148
42.5k6108148
add a comment |Â
add a comment |Â
up vote
0
down vote
There are three different ways to force bash
to be POSIX compliant.
- Start
bash
with--posix
option - Set option posix while bash is already running:
set -o posix
Use environment variable
POSIXLY_CORRECT
:
If this variable is in the environment when bash starts, the shell
enters posix mode before reading the startup files, as if the--posix
invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the commandset -o posix
had been executed.
Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.
add a comment |Â
up vote
0
down vote
There are three different ways to force bash
to be POSIX compliant.
- Start
bash
with--posix
option - Set option posix while bash is already running:
set -o posix
Use environment variable
POSIXLY_CORRECT
:
If this variable is in the environment when bash starts, the shell
enters posix mode before reading the startup files, as if the--posix
invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the commandset -o posix
had been executed.
Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
There are three different ways to force bash
to be POSIX compliant.
- Start
bash
with--posix
option - Set option posix while bash is already running:
set -o posix
Use environment variable
POSIXLY_CORRECT
:
If this variable is in the environment when bash starts, the shell
enters posix mode before reading the startup files, as if the--posix
invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the commandset -o posix
had been executed.
Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.
There are three different ways to force bash
to be POSIX compliant.
- Start
bash
with--posix
option - Set option posix while bash is already running:
set -o posix
Use environment variable
POSIXLY_CORRECT
:
If this variable is in the environment when bash starts, the shell
enters posix mode before reading the startup files, as if the--posix
invocation option had been supplied. If it is set while the shell is running, bash enables posix mode, as if the commandset -o posix
had been executed.
Using these trio one can write some extension (e.g. function loaded during bash start-up), and probably someone already did this, but none of them are bash standard.
answered Jan 13 at 20:05
jimmij
28.9k867100
28.9k867100
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416893%2fcan-i-view-bash-posix-extensions%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
This sounds somewhat confusing, and confused. It would probably be easier to understand what you mean if we saw any of the (many) sources you refer to. Bash supports extensions to the POSIX shell language, that is, features that are not defined by POSIX. It can also run in a POSIX-compatible mode, but calling that an "extension" seems very odd.
â ilkkachu
Jan 13 at 20:09