mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Bashisms shopt, complete
This commit is contained in:
parent
9eef76fcad
commit
19ea4d3af9
3 changed files with 36 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
**Added:**
|
||||
|
||||
* Added ``unset``, ``export``, ``set -e``, ``set -x`` to xontrib bashisms.
|
||||
* Added ``unset``, ``export``, ``set -e``, ``set -x``, ``shopt``, ``complete`` to xontrib bashisms.
|
||||
|
||||
**Changed:**
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
"**Warning:** This xontrib may modify user command line input to implement ",
|
||||
"its behavior. To see the modifications as they are applied (in unified diff",
|
||||
"format), please set ``$XONSH_DEBUG`` to ``2`` or higher.\n\n",
|
||||
"Limited support of bash commands: ``alias``, ``export``, ``unset``, ``set``."]
|
||||
"The xontrib also adds commands: ``alias``, ``export``, ``unset``, ``set``, ``shopt``, ``complete``."]
|
||||
},
|
||||
{"name": "base16_shell",
|
||||
"package": "xontrib-base16-shell",
|
||||
|
|
|
@ -113,3 +113,37 @@ def _set(args):
|
|||
|
||||
|
||||
aliases["set"] = _set
|
||||
|
||||
|
||||
def _shopt(args):
|
||||
|
||||
supported_shopt = ["DOTGLOB"]
|
||||
|
||||
args_len = len(args)
|
||||
if args_len == 0:
|
||||
for so in supported_shopt:
|
||||
onoff = "on" if so in __xonsh__.env and __xonsh__.env[so] else "off"
|
||||
print(f"dotglob\t{onoff}")
|
||||
return
|
||||
elif args_len < 2 or args[0] in ["-h", "--help"]:
|
||||
print(f'Usage: shopt <-s|-u> <{"|".join(supported_shopt).lower()}>')
|
||||
return
|
||||
|
||||
opt = args[0]
|
||||
optname = args[1]
|
||||
|
||||
if opt == "-s" and optname == "dotglob":
|
||||
__xonsh__.env["DOTGLOB"] = True
|
||||
elif opt == "-u" and optname == "dotglob":
|
||||
__xonsh__.env["DOTGLOB"] = False
|
||||
else:
|
||||
print(
|
||||
"Not supported in xontrib bashisms.\nPRs are welcome - https://github.com/xonsh/xonsh/blob/master/xontrib/bashisms.py",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
|
||||
aliases["shopt"] = _shopt
|
||||
|
||||
|
||||
aliases["complete"] = "completer list"
|
||||
|
|
Loading…
Add table
Reference in a new issue