0

Sometimes a same command is provided by shell-builtin as well as other file/package. Example:

$ type -a printf kill
printf is a shell builtin
printf is /usr/bin/printf
kill is a shell builtin
kill is /bin/kill

And while executing command, I sometime face some difficulties or command doesn't work as expected.

Example from man kill:

-L, --table
              List signal names in a nice table.

And If I try from terminal, it doesn't work:

$ kill -L
bash: kill: L: invalid signal specification

This is because kill is executing as shell-builtin and it has no such feature/option.

So, How do I execute command properly to avoid interference from the shell?

Note: Here kill is only used to give an example. You may have difficulties with other command(s) that have interference from shell

Pandya
  • 24,618

1 Answers1

3

You can use env your-command to avoid interference from the shell.

Example:

$ env kill -L
 1 HUP      2 INT      3 QUIT     4 ILL      5 TRAP     6 ABRT     7 BUS
 8 FPE      9 KILL    10 USR1    11 SEGV    12 USR2    13 PIPE    14 ALRM
15 TERM    16 STKFLT  17 CHLD    18 CONT    19 STOP    20 TSTP    21 TTIN
22 TTOU    23 URG     24 XCPU    25 XFSZ    26 VTALRM  27 PROF    28 WINCH
29 POLL    30 PWR     31 SYS     

Another way is to use the path of command as follows:

$ which kill
/bin/kill

$ /bin/kill -L
 1 HUP      2 INT      3 QUIT     4 ILL      5 TRAP     6 ABRT     7 BUS
 8 FPE      9 KILL    10 USR1    11 SEGV    12 USR2    13 PIPE    14 ALRM
15 TERM    16 STKFLT  17 CHLD    18 CONT    19 STOP    20 TSTP    21 TTIN
22 TTOU    23 URG     24 XCPU    25 XFSZ    26 VTALRM  27 PROF    28 WINCH
29 POLL    30 PWR     31 SYS    

So, By using env or specifying the path/location of command you can avoid interference from the shell.

Pandya
  • 24,618