Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in Linux "which source" returns nothing?

I want to source some shell scripts in c using exec().

What is source ? is that a binary executable or a shell script ? where can i find that in linux file system ?

I ran

charan@PC-113:~$ which source 

charan@PC-113:~$
like image 976
Charan Pai Avatar asked Dec 15 '22 08:12

Charan Pai


1 Answers

It is a builtin shell command, like cd, exit, pwd...:

$ enable -p | grep source
enable source

Note that enable -p shows all the builtins. More info in enable Man page.

Update

Just saw a pretty interesting thread in SuperUser: What does source do?

$ type source
source is a shell builtin

Update 2 - comment by Tony D

@SIGSEGV: sometimes a command can be implemented as an external (non-shell) executable, but some shells will still want to provide their own implementation... possibly with different behaviour, possibly just to make it faster. test and pwd are examples of this. For example, the shell can get its current working directory using getcwd(), but if it runs a separate executable without changing the current directory for that executable, and the executable runs getcwd() - it still works.

like image 99
fedorqui 'SO stop harming' Avatar answered Dec 29 '22 12:12

fedorqui 'SO stop harming'