2
votes
2answers
118 views

Why does Bash's “source” command behave differently when called from a function?

Given the following sourceable bar Bash script ... echo :$#:"$@": ... and the following executable foo Bash script: echo -n source bar: source bar echo -n source bar foo: source bar foo function ...
1
vote
1answer
42 views

Understand `compgen` builtin command

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] ...
7
votes
2answers
285 views

Change the order of executables started in bash

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 ...
5
votes
2answers
103 views

Default preference of executable over built-ins with the same name

I was playing around a bit with the names of some executables, putting them in a folder, ~/bin, which is in my $PATH. Now I'm wondering how I can set the preferences of a bash-3.2 terminal so that it ...
1
vote
2answers
130 views

How to invoke a shell built-in explicitly?

I want to customize the functionality of cd command as per my needs. I define following function - function cd () { cd "$@" && pushd "$@"; } The intent of this function is to automatically ...
4
votes
3answers
333 views

Why is bash's printf faster than /usr/bin/printf?

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, ...
7
votes
2answers
363 views

Possible to use brace (permutation) and array expansion simultaneously?

Bash's {} brace expansion syntax allows for creating easy permutations # echo {b,c,d}{a,e,i,o,u} ba be bi bo bu ca ce ci co cu da de di do du However it's not clear to me if/how it's possible to ...
12
votes
4answers
1k views

Make bash use external `time` command rather than shell built-in

How can I make bash use time binary (/usr/bin/time) by default instead of the shell keyword? which time returns /usr/bin/time type time returns time is a shell keyword Running time is obviously ...
1
vote
1answer
200 views

Bash pipe output to more

I am wondering about some bash environment setting here: is it possible to set stdout of bash as a pipe to /bin/more? You know, like using vi as editor for your commands it should be possible to avoid ...
1
vote
3answers
144 views

In bash, how can I erase an alias without logout? [duplicate]

I had an alias in my .bashrc and I really don't want it anymore. I erased the alias, but my bash already has this alias loaded. Can I erase this alias from this bash without logging out?
2
votes
1answer
114 views

An -e option to cd builtin

According to Bash reference on Bash builtins: cd [-L|[-P [-e]]] [directory] The -P option means to not follow symbolic links; symbolic links are followed by default or with the -L option. ...
2
votes
6answers
323 views

bash equivalent of this use of tcsh “sched” command?

In tcsh, the built-in sched command causes a command to be executed by the current shell at a specified time. I have the following $HOME/.sched file (this is a simplified version of it): setenv ...
4
votes
1answer
268 views

Why are parameters to Bash's builtin optional?

Running simply builtin prints nothing and returns exit code 0. This is in accordance with help builtin, which shows all parameters as optional. But why isn't this no-op an error? Is there a use case ...
16
votes
2answers
2k views

Can I get individual man pages for the bash builtin commands? [duplicate]

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 ...
3
votes
2answers
2k views

Why does my shell script give the error: “declare: not found”?

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 ...
32
votes
4answers
3k views

What is the difference between a builtin command and one that is not?

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 ...
3
votes
2answers
844 views

Capture multi-line output of a bash builtin

Normally, bash is able to assign multi-line output of a command: L=`ls` This works from both interactive shell and scripts. But it appears the output of a builtin can't be captured in a variable: ...