help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shopt and set builtins


From: Chet Ramey
Subject: Re: shopt and set builtins
Date: Sat, 21 Nov 2020 12:58:14 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.4.3

On 11/20/20 11:51 PM, Kevin Shell wrote:
> Hello Bash list.
> 
> I often confused by whether to use "shopt" or "set".
> It seems the functionality of "shopt" is quite similar to that of "set".
> 
> Why it's necessary to add the builtin command "shopt" to Bash?
> When to use "shopt" rather than "set"?

I created `shopt' because I wanted something that wouldn't be subject
to `set's limitations: the requirement to use so many of the single-
letter options, the inability to query an option's status, the use of
`+' to turn options off, and the fact that POSIX controlled the option
namespace.

Since `shopt -o' manipulates the `set -o' namespace, you don't ever have
to use `set' for scripts that will only run with bash. If you want
portability, you can use `set' for the subset of options common across
implementations.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]