tomerfiliba / plumbum

Plumbum: Shell Combinators
https://plumbum.readthedocs.io
MIT License
2.91k stars 188 forks source link

Invoking bash builtin commands #603

Open youk opened 3 years ago

youk commented 3 years ago

Is there any way to invoke bash builtin command like trap? Regular approach results in plumbum.commands.processes.CommandNotFound.

zahlman commented 1 month ago

Try explicitly invoking bash -c to process the command (the flag or other syntax needed may be shell-dependent). For example, on my system:

>>> from plumbum.cmd import bash, head
>>> from plumbum import FG
>>> (bash['-c', 'help', 'help'] | head['-n', 5]) & FG
GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.