Questions tagged [shell-builtin]
A shell builtin is a command called from a shell, that is executed directly in the shell itself.
173 questions
5 votes
2 answers
571 views
Why doesn't the pwd nullary built-in error when provided an argument, whereas the nullary/unary exit built-in does error?
If I enter pwd foo bar at the prompt of the bash shell, the foo bar part of the command line seems to be completely ignored. If I enter exit 0 foo, I get bash: exit: too many arguments. So pwd ignored ...
-5 votes
1 answer
99 views
To have ., the source synonym, workable [closed]
The bash' command source has been modified in one of few ways: alias function overriding or else Then how can its synonym: . got being so too (problem is it's not letter) ?
0 votes
2 answers
106 views
What explains the measured overhead when timing a command in zsh?
When timing a command with time, there is inevitably some overhead (from the CPU, operating system, shell and so on). Running the following code, from a tty text mode virtual console with all ...
2 votes
1 answer
207 views
`printf` and `time` formatting issues in a `zsh` shell script
I have the following (excerpt from a) zsh shell script (the FOLDER environment variable is exported earlier in the code): # Create temporary directory export TMPDIR=$(mktemp -d) # Set TIMEFMT to ...
0 votes
0 answers
35 views
Why does `<command> | tee /dev/tty | :` (where `:` is the "no effect" or "does nothing" bash builtin) display nothing? [duplicate]
I wanted to use tee /dev/tty to look into the stream passing through a pipeline. While making some tests, I observed the following: ~$ cd /proc/self/fd /proc/self/fd$ ls 0 1 2 255 # Ok /proc/self/...
2 votes
4 answers
1k views
printf as a bash builtin vs an executable (behavior differences)
I am trying to better understand printf so I read multiple pages on this command, but I also stumbled upon different behavior of %q directive. Namely, stated on this page: What is the difference ...
4 votes
0 answers
114 views
Why is `fc` output different through a pipe in a subshell?
Why does echo "$(fc -l -1)" show the previous command, but echo "$(fc -l -1 | cat)" show the current command? $ testfc () { > echo "$(fc -l -1)" > echo &...
-2 votes
2 answers
348 views
Dangerous behavior of the `cd` built-in
I was plodding along, working on a shell script, and I've just learned something that I found surprising. I'm presenting it here as a Question because I'd like to learn if there's some way to avoid ...
3 votes
1 answer
366 views
Bash builtin 'command' ignoring option '-p'
I am trying to add this to my ~/.bashrc and test for some commands, that already have aliases. command -pv <command> but it seems like the -p option that is supposed to force a path search is ...
1 vote
0 answers
189 views
exit from running, sourcing, or pasting a series of commands in bash
I'm writing a script that I run directly, "source" from the bash console, or cut/paste as a sequence of commands into a console from an editor window. The script or its pasted commands may ...
0 votes
1 answer
196 views
Can bash natively re-format a relative path to an absolute path, or not - being dependent on tool "realpath"?
UPDATE Once again, I can't post an answer to my question! Clicking the button just triggers an error message: "Unable to load popup - please try again". So, I have no other choice than to ...
1 vote
2 answers
316 views
How do I use a nonstandard file descriptor for reading a file into an array with mapfile?
mapfile -t -u 7 arr < textfile gives me bash: mapfile: 7: invalid file descriptor: Bad file descriptor Other, more verbose, methods of reading files line-by-line do allow for such descriptor, e.g. ...
1 vote
2 answers
288 views
How To Auto `command -p` In All My Script?
I want to execute all commands within my script with command -p e.g.: command -p pwd Because there may be some command that I will execute within the script whose name is being used by some other ...
-1 votes
1 answer
290 views
Is the following `readonly` use POSIX-ly correct?
I defined the following as read-only: readonly root_command='sudo -s' later used in my script as in: exec $root_command My question is, maybe I am slow or something, but I do not fully understand ...
1 vote
2 answers
186 views
How to avoid kickout from SSH when script fail
Please forgive my basic unix/linux scripting skill and poor English I am testing a script in the Linux VM, let's say it is work.sh. So I have to ssh to the VM ssh [email protected] with my ...