shell-builtin's questions - Chinese 1answer

91 shell-builtin questions.

if I run nrolland@mactoasty ~ $ type -p skhd skhd is /usr/local/bin/skhd I can't compose it nicely with other command like nrolland@mactoasty ~ $ la `type -p skhd` ls: is: No such file or ...

In in the bash manual, it's written that Builtin commands are contained >>> within <<< the shell itself Also, this answer states that A built-in command is simply a command that ...

eval and exec are both built in commands of bash(1) that execute commands. I also see exec has a few options but is that the only difference? What happens to their context?

env and printenv are both external commands i.e. executable files, not bash builtins. The problem with them is that some environment variables (such as _, and I also wonder if there are more) which ...

How can I acquire an fd for reading with Bash so that I can branch on the exit code without any further side effects? This is success and failure without the branch: $ set -u # -ue actually $ exec {...

I am aware that aliases can be bypassed by quoting the command itself. However, it seems that if builtin commands are "shadowed" by functions with the same names, there is no way to execute the ...

I use Bash as my interactive shell and I was wondering if there was an easy way to get Bash to run a system command instead of a shell builtin command in the case where they both share the same name. ...

I want to time reading bash history and put the result into a variable. Unfortunately, time (which is a shell keyword) prints the result to stderr, and apparently redirecting stderr from shell ...

Consider a situation that I run these commands in my current shell or I put them inside .bashrc: alias source='echo hi' alias .='echo hi' alias unalias='echo hi' Or function source(){ echo hi; }, ...

What's the point of the builtin builtin when the command builtin has the exact same functionality when it comes to looking up builtins? When making sure that a particular builtin is chosen over a ...

I want to customize the functionality of cd command as per my needs. I defined the following function - function cd () { cd "$@" && pushd "$@"; } The intent of this function is to ...

When I use the type command to find out if cat is a shell built-in or an external program I get the output below: -$ type cat cat is hashed (/bin/cat) -$ Does this mean that cat is an external ...

I wrote a function to handle unknown commands in bash via command_not_found_handle (). My intention is to source scripts on demand and access its functions inside the handler. But unfortunately the ...

summary: If in bash I attempt to assign the output of a missing function to a previously-declared (i.e., not {constant, read-only}) variable, I can detect the failure with "normal" tests. But if I ...

I know we can print a sequence of letters of the Alphabet using echo command and experimented it a little by doing this. Lowercase letter Sequence $ echo {a..z} a b c d e f g h i j k l m n o p q r s ...

I have seen How do I use pushd and popd commands? , and I am aware that with pushd <dir> I would push <dir> to the directory stack, with popd I would pop the top directory from the ...

Is there any intrinsic difference between a builtin command and another command which can nominally do the same thing? eg. Do builtins get "special" treatement? ... is there less overhead running ...

I've hacked on a lot of shell scripts, and sometimes the simplest things baffle me. Today I ran across a script that made extensive use of the : (colon) bash builtin. The documenation seems simple ...

What is the difference between shell builtins (like cd or echo) and shell keyboard shortcuts (like ctrl+u or ctrl+l)? Both seems to me "builtins", what is the major difference by means of system ...

According to this comment which is in defense of the author's answer, @einpoklum Yes, it is necessary. In fact, even this solution may break in one edge case. Thanks for bringing this to my ...

I've always wondered why cd isn't a program, but never managed to find the answer. Anyone know why this is the case?

Is there a more idiomatic way to express the following? xargs -r -l1 -I % bash -c 'cat <(echo %)' Where cat stands for intended program that does not accept relevant argument from command line, ...

Where can I find more information about the command(?) print since I don't receive a result when I input man print? For example, in the zsh I can do the following: $ print "Hello, world\!" Hello, ...

Please correct me if I am wrong: When a bash shell runs an external executable program, the bash shell will create a child process to run the program in foreground. If there is any key-generated ...

06/26/2017 23:40:40 CAUAJM_I_10082 [aspsun14 connected for IOALPPRXXBD_ALPGLGENFAALL 55443.15215291.1] 06/26/2017 23:40:40 CAUAJM_I_40245 EVENT: CHANGE_STATUS STATUS: STARTING ...

I know that external commands are run in the shell by creating a separate process, but what exactly happens when a built-in command is run in a shell? Are they executed as a function, or does the ...

I looked up the shell builtin command set by typing help set, and the short syntax description shows: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...] The help-documentation explains, ...

Some commands are provided as both builtins and external utilities. Take echo for example. On my machine (macOS) running Bash 3.2, $ type echo echo is a shell builtin Running man bash | less --...

Is there anywhere you can download a manpage for every builtin commands? I know you can just use help or man bash and search to find info about it, but I want them separated, so I can just do man ...

I am wanting to build a custom builtin in bash -- like time for example. Is this possible? If it's not, is it possible in another shell? For example, I want to do this: map find -name '*.js' | xargs ...

I typed help suspend and got this short explanation: suspend: suspend [-f] Suspend shell execution. Suspend the execution of this shell until it receives a SIGCONT signal. Unless forced, ...

I switched the shell on my main account to zsh and when installing a script that logs history to a database, https://github.com/larkery/zsh-histdb, I saw that some typeset commands in them didn't work,...

Here is a simple example showing that using declare in a script the script will not run, while sourcing the script will: $ cat /tmp/new #! /bin/sh declare -i hello $ chmod a+rwx /tmp/new $ /tmp/new /...

The purpose of this question is to answer a curiosity, not to solve a particular computing problem. The question is: Why are POSIX mandatory utilities not commonly built into shell implementations? ...

I have two ways of calling printf on my system: $ type -a printf printf is a shell builtin printf is /usr/bin/printf $ file /usr/bin/printf /usr/bin/printf: ELF 64-bit LSB executable, x86-64, ...

$ which echo echo: shell built-in command. $ which ls /bin/ls $ which cat /bin/cat Why is echo not an independent utility like ls, ps, cat etc? Why is it shell specific? Any good reasons?

I have a file with my Raspberry Pi address named pi. It's in my home directory. pi=192.168.0.173 To connect to the Pi, I'd do this in my home directory: . pi && ssh pi@$pi It worked. Then ...

From help compgen: $ help compgen compgen: compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word] ...

If I execute the test command in bash, test(evaluates conditional expression) built-in utility is started: $ type test test is a shell builtin $ type -a test test is a shell builtin test is /usr/...

This question is a variant on a previously asked How to repeat currently typed in parameter on bash console? Many a time, I find myself wanting to slightly rename a file name in the shell, e.g.: $ ...

I'm normally well aware of the contents of $-. On a recent CentOS I get: [grochmal@orion ~]$ echo $- himBH hmBH are all options from set, and i means that my shell is interactive. Yet, on my Arch ...

I'm trying to understand some kernel level concepts in Linux. I was checking on the difference between shell builtin commands and the other executable commands. This wonderful answer clearly tells ...

(Note that this is entirely an academic question... I'm just curious about the answer, not trying to solve any particular problem.) From the ECHO(1) manual page (GNU echo): NOTE: your shell may ...

I am writing my own shell. I want to implement redirection( > and >>). For that I have used dup2() system call. But if a command I enter has redirection, another command follows the previous ...

Context: an AIX lpar with very low memory (no forking possible, so only shell's builtins (cd, echo, kill) will work). I can have a (hmc) console to it, but I need a better way to start freing memory ...

Consider the below scenario 2 vms - 192.168.229.131, 192.168.229.132 Both the vms has it's ip as 192.168.229.151 & 192.168.229.152 in it's /etc/hosts file Say there are around 50 vms like I ...

If I want to get a brief usage message for a bash builtin, I can use help <builtin> at a command prompt, e.g. $ help export export: export [-fn] [name[=value] ...] or export -p Set export ...

I don't know the exact word, that's why I'll use "decorator", like in POO, but I'm talking about the kind of functions you can use before other functions to add any operations to it, like the command ...

When there are same-name builtin, keyword and/or external command, what is the order in which the Bash shell decides which to run? For example, keyword time and external command time, builtin ...

Consider this from the documentation of Bash' builtin exec: exec replaces the shell without creating a new process Please provide a use case / practical example. I don’t understand how this makes ...

Related tags

Hot questions

Language

Popular Tags