What is the difference between the terms “program”, “command” and “function” in Linux & Unix?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
11
down vote

favorite












I would like to know whether the commands that we call in the shell are functions or programs?










share|improve this question



















  • 1




    What distinction are you making between "small program" and "function"?
    – JdeBP
    Sep 13 at 12:10










  • You can enter commands into a shell program that let you program the shell to function and take command utilizing functions that the shell was programmed with to command other programs from the shell functions.
    – txtechhelp
    Sep 14 at 1:32














up vote
11
down vote

favorite












I would like to know whether the commands that we call in the shell are functions or programs?










share|improve this question



















  • 1




    What distinction are you making between "small program" and "function"?
    – JdeBP
    Sep 13 at 12:10










  • You can enter commands into a shell program that let you program the shell to function and take command utilizing functions that the shell was programmed with to command other programs from the shell functions.
    – txtechhelp
    Sep 14 at 1:32












up vote
11
down vote

favorite









up vote
11
down vote

favorite











I would like to know whether the commands that we call in the shell are functions or programs?










share|improve this question















I would like to know whether the commands that we call in the shell are functions or programs?







shell command-line function bash-functions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 13 at 17:52









Benjamin W.

413311




413311










asked Sep 13 at 11:11









Lion

957




957







  • 1




    What distinction are you making between "small program" and "function"?
    – JdeBP
    Sep 13 at 12:10










  • You can enter commands into a shell program that let you program the shell to function and take command utilizing functions that the shell was programmed with to command other programs from the shell functions.
    – txtechhelp
    Sep 14 at 1:32












  • 1




    What distinction are you making between "small program" and "function"?
    – JdeBP
    Sep 13 at 12:10










  • You can enter commands into a shell program that let you program the shell to function and take command utilizing functions that the shell was programmed with to command other programs from the shell functions.
    – txtechhelp
    Sep 14 at 1:32







1




1




What distinction are you making between "small program" and "function"?
– JdeBP
Sep 13 at 12:10




What distinction are you making between "small program" and "function"?
– JdeBP
Sep 13 at 12:10












You can enter commands into a shell program that let you program the shell to function and take command utilizing functions that the shell was programmed with to command other programs from the shell functions.
– txtechhelp
Sep 14 at 1:32




You can enter commands into a shell program that let you program the shell to function and take command utilizing functions that the shell was programmed with to command other programs from the shell functions.
– txtechhelp
Sep 14 at 1:32










3 Answers
3






active

oldest

votes

















up vote
16
down vote













It depends.



Commands can fall into multiple categories: builtins, aliases,
functions, executables (scripts and binaries in the search path).



On the command line, these occupy a single, flat namespace which
makes overriding possible. There are numerous ways of telling
kinds of programs apart:



$ f () :; 
$ alias a=cat
$ which f
f ()

:



We know that f is a function.



$ which a
alias a='cat'
/usr/bin/cat


We know that a is an alias.



$ which yes
/usr/bin/yes


We know that yes is a program.



$ builtin echo ; echo $?

0


The shell has an echo builtin …



$ builtin cat ; echo $?
bash: builtin: cat: not a shell builtin
1


… but none for cat. If there is a builtin or an alias
but you insist on calling the program instead, prefix the
command with a backslash:



$ builtin true | printf "%dn" $?
0
$ alias true=false
$ true ; printf "%dn" $?
1
$ true ; printf "%dn" $?
0





share|improve this answer
















  • 3




    Also, a command that's a program in one implementation of *nix might well become a shell builtin (= function) in another.
    – jamesqf
    Sep 13 at 15:14






  • 1




    @jamesqf, yeah, shell's have standard tools built in, but builtin commands are not the same as functions. Run e.g. sh -c 'type true; f() echo x; ; type f'
    – ilkkachu
    Sep 13 at 17:16






  • 5




    Note that in general, type is preferable to which for almost all purposes. See unix.stackexchange.com/q/85249/135943
    – Wildcard
    Sep 13 at 18:00










  • @ilkkachu: That depends on your definition of "the same as". Of course they are implemented differently, but to the ordinary user typing a command, they are functionally the same.
    – jamesqf
    Sep 14 at 17:05






  • 1




    @jamesqf, even if your ordinary user doesn't (know how to) use functions, claiming they're the same as builtins is just confusing.
    – ilkkachu
    Sep 14 at 18:46

















up vote
7
down vote













The definition of a function is returning single values, and does not output anything. Shell functions in particular may very well and could have an output or other side effects, since the return value of functions is so limited.



A command is an instruction given by a user to tell a computer to do something, for example, executing a single program or a group of linked programs.



A program is a sequence of instructions (i.e. commands) that are given to a computer and understandable by the computer's central processing unit (CPU). these instructions indicates which operations the computer should perform on a set of data.



Having said that, functions are logical subset of the program. Calling one is entirely within your process. The command is a program (or a shell built-in) can be executed from the command shell. The command implements functions which perform a task. The opposite is not correct.






share|improve this answer


















  • 10




    "a function returns a single value, and does not output anything" -- well, yeah, in the mathematical sense maybe. But in imperative programming languages, it's really common for "function" to mean just a subroutine, one that could do anything. And shell functions in particular may very well have output or other side effects, since the return value of functions is so limited.
    – ilkkachu
    Sep 13 at 11:51










  • @ilkkachu. Thank you. I have updated the answer. Please feel free to revise ;-)
    – Goro
    Sep 13 at 11:56






  • 3




    I think these definitions are from a programming-language context, not a shell context. Yes, I know the shell language is a programming language, but its idea of a "function" is quite different to the mathematical or computer-science definition - in shell, all commands (whether builtins, functions, aliases, programs or scripts) act alike, and are simply different kinds of implementation.
    – Toby Speight
    Sep 13 at 16:51







  • 1




    ...*mostly* alike; builtins can change the state of the shell itself, whereas external programs can't call chdir() or setenv() in the shell that is, to them, a distinct parent process.
    – Charles Duffy
    Sep 13 at 17:51

















up vote
1
down vote














I would like to know whether the commands that we call in the shell are functions or programs?




Yes.



Specifically, when you type in some text and press enter, the shell must determine whether it's:



  1. an alias,

  2. a function,

  3. a built-in command,

  4. an executable file.





share|improve this answer


















  • 1




    @jlliagre thanks. Will edit the answer.
    – RonJohn
    Sep 13 at 17:36










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468764%2fwhat-is-the-difference-between-the-terms-program-command-and-function-in%23new-answer', 'question_page');

);

Post as a guest






























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
16
down vote













It depends.



Commands can fall into multiple categories: builtins, aliases,
functions, executables (scripts and binaries in the search path).



On the command line, these occupy a single, flat namespace which
makes overriding possible. There are numerous ways of telling
kinds of programs apart:



$ f () :; 
$ alias a=cat
$ which f
f ()

:



We know that f is a function.



$ which a
alias a='cat'
/usr/bin/cat


We know that a is an alias.



$ which yes
/usr/bin/yes


We know that yes is a program.



$ builtin echo ; echo $?

0


The shell has an echo builtin …



$ builtin cat ; echo $?
bash: builtin: cat: not a shell builtin
1


… but none for cat. If there is a builtin or an alias
but you insist on calling the program instead, prefix the
command with a backslash:



$ builtin true | printf "%dn" $?
0
$ alias true=false
$ true ; printf "%dn" $?
1
$ true ; printf "%dn" $?
0





share|improve this answer
















  • 3




    Also, a command that's a program in one implementation of *nix might well become a shell builtin (= function) in another.
    – jamesqf
    Sep 13 at 15:14






  • 1




    @jamesqf, yeah, shell's have standard tools built in, but builtin commands are not the same as functions. Run e.g. sh -c 'type true; f() echo x; ; type f'
    – ilkkachu
    Sep 13 at 17:16






  • 5




    Note that in general, type is preferable to which for almost all purposes. See unix.stackexchange.com/q/85249/135943
    – Wildcard
    Sep 13 at 18:00










  • @ilkkachu: That depends on your definition of "the same as". Of course they are implemented differently, but to the ordinary user typing a command, they are functionally the same.
    – jamesqf
    Sep 14 at 17:05






  • 1




    @jamesqf, even if your ordinary user doesn't (know how to) use functions, claiming they're the same as builtins is just confusing.
    – ilkkachu
    Sep 14 at 18:46














up vote
16
down vote













It depends.



Commands can fall into multiple categories: builtins, aliases,
functions, executables (scripts and binaries in the search path).



On the command line, these occupy a single, flat namespace which
makes overriding possible. There are numerous ways of telling
kinds of programs apart:



$ f () :; 
$ alias a=cat
$ which f
f ()

:



We know that f is a function.



$ which a
alias a='cat'
/usr/bin/cat


We know that a is an alias.



$ which yes
/usr/bin/yes


We know that yes is a program.



$ builtin echo ; echo $?

0


The shell has an echo builtin …



$ builtin cat ; echo $?
bash: builtin: cat: not a shell builtin
1


… but none for cat. If there is a builtin or an alias
but you insist on calling the program instead, prefix the
command with a backslash:



$ builtin true | printf "%dn" $?
0
$ alias true=false
$ true ; printf "%dn" $?
1
$ true ; printf "%dn" $?
0





share|improve this answer
















  • 3




    Also, a command that's a program in one implementation of *nix might well become a shell builtin (= function) in another.
    – jamesqf
    Sep 13 at 15:14






  • 1




    @jamesqf, yeah, shell's have standard tools built in, but builtin commands are not the same as functions. Run e.g. sh -c 'type true; f() echo x; ; type f'
    – ilkkachu
    Sep 13 at 17:16






  • 5




    Note that in general, type is preferable to which for almost all purposes. See unix.stackexchange.com/q/85249/135943
    – Wildcard
    Sep 13 at 18:00










  • @ilkkachu: That depends on your definition of "the same as". Of course they are implemented differently, but to the ordinary user typing a command, they are functionally the same.
    – jamesqf
    Sep 14 at 17:05






  • 1




    @jamesqf, even if your ordinary user doesn't (know how to) use functions, claiming they're the same as builtins is just confusing.
    – ilkkachu
    Sep 14 at 18:46












up vote
16
down vote










up vote
16
down vote









It depends.



Commands can fall into multiple categories: builtins, aliases,
functions, executables (scripts and binaries in the search path).



On the command line, these occupy a single, flat namespace which
makes overriding possible. There are numerous ways of telling
kinds of programs apart:



$ f () :; 
$ alias a=cat
$ which f
f ()

:



We know that f is a function.



$ which a
alias a='cat'
/usr/bin/cat


We know that a is an alias.



$ which yes
/usr/bin/yes


We know that yes is a program.



$ builtin echo ; echo $?

0


The shell has an echo builtin …



$ builtin cat ; echo $?
bash: builtin: cat: not a shell builtin
1


… but none for cat. If there is a builtin or an alias
but you insist on calling the program instead, prefix the
command with a backslash:



$ builtin true | printf "%dn" $?
0
$ alias true=false
$ true ; printf "%dn" $?
1
$ true ; printf "%dn" $?
0





share|improve this answer












It depends.



Commands can fall into multiple categories: builtins, aliases,
functions, executables (scripts and binaries in the search path).



On the command line, these occupy a single, flat namespace which
makes overriding possible. There are numerous ways of telling
kinds of programs apart:



$ f () :; 
$ alias a=cat
$ which f
f ()

:



We know that f is a function.



$ which a
alias a='cat'
/usr/bin/cat


We know that a is an alias.



$ which yes
/usr/bin/yes


We know that yes is a program.



$ builtin echo ; echo $?

0


The shell has an echo builtin …



$ builtin cat ; echo $?
bash: builtin: cat: not a shell builtin
1


… but none for cat. If there is a builtin or an alias
but you insist on calling the program instead, prefix the
command with a backslash:



$ builtin true | printf "%dn" $?
0
$ alias true=false
$ true ; printf "%dn" $?
1
$ true ; printf "%dn" $?
0






share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 13 at 11:29









phg

628417




628417







  • 3




    Also, a command that's a program in one implementation of *nix might well become a shell builtin (= function) in another.
    – jamesqf
    Sep 13 at 15:14






  • 1




    @jamesqf, yeah, shell's have standard tools built in, but builtin commands are not the same as functions. Run e.g. sh -c 'type true; f() echo x; ; type f'
    – ilkkachu
    Sep 13 at 17:16






  • 5




    Note that in general, type is preferable to which for almost all purposes. See unix.stackexchange.com/q/85249/135943
    – Wildcard
    Sep 13 at 18:00










  • @ilkkachu: That depends on your definition of "the same as". Of course they are implemented differently, but to the ordinary user typing a command, they are functionally the same.
    – jamesqf
    Sep 14 at 17:05






  • 1




    @jamesqf, even if your ordinary user doesn't (know how to) use functions, claiming they're the same as builtins is just confusing.
    – ilkkachu
    Sep 14 at 18:46












  • 3




    Also, a command that's a program in one implementation of *nix might well become a shell builtin (= function) in another.
    – jamesqf
    Sep 13 at 15:14






  • 1




    @jamesqf, yeah, shell's have standard tools built in, but builtin commands are not the same as functions. Run e.g. sh -c 'type true; f() echo x; ; type f'
    – ilkkachu
    Sep 13 at 17:16






  • 5




    Note that in general, type is preferable to which for almost all purposes. See unix.stackexchange.com/q/85249/135943
    – Wildcard
    Sep 13 at 18:00










  • @ilkkachu: That depends on your definition of "the same as". Of course they are implemented differently, but to the ordinary user typing a command, they are functionally the same.
    – jamesqf
    Sep 14 at 17:05






  • 1




    @jamesqf, even if your ordinary user doesn't (know how to) use functions, claiming they're the same as builtins is just confusing.
    – ilkkachu
    Sep 14 at 18:46







3




3




Also, a command that's a program in one implementation of *nix might well become a shell builtin (= function) in another.
– jamesqf
Sep 13 at 15:14




Also, a command that's a program in one implementation of *nix might well become a shell builtin (= function) in another.
– jamesqf
Sep 13 at 15:14




1




1




@jamesqf, yeah, shell's have standard tools built in, but builtin commands are not the same as functions. Run e.g. sh -c 'type true; f() echo x; ; type f'
– ilkkachu
Sep 13 at 17:16




@jamesqf, yeah, shell's have standard tools built in, but builtin commands are not the same as functions. Run e.g. sh -c 'type true; f() echo x; ; type f'
– ilkkachu
Sep 13 at 17:16




5




5




Note that in general, type is preferable to which for almost all purposes. See unix.stackexchange.com/q/85249/135943
– Wildcard
Sep 13 at 18:00




Note that in general, type is preferable to which for almost all purposes. See unix.stackexchange.com/q/85249/135943
– Wildcard
Sep 13 at 18:00












@ilkkachu: That depends on your definition of "the same as". Of course they are implemented differently, but to the ordinary user typing a command, they are functionally the same.
– jamesqf
Sep 14 at 17:05




@ilkkachu: That depends on your definition of "the same as". Of course they are implemented differently, but to the ordinary user typing a command, they are functionally the same.
– jamesqf
Sep 14 at 17:05




1




1




@jamesqf, even if your ordinary user doesn't (know how to) use functions, claiming they're the same as builtins is just confusing.
– ilkkachu
Sep 14 at 18:46




@jamesqf, even if your ordinary user doesn't (know how to) use functions, claiming they're the same as builtins is just confusing.
– ilkkachu
Sep 14 at 18:46












up vote
7
down vote













The definition of a function is returning single values, and does not output anything. Shell functions in particular may very well and could have an output or other side effects, since the return value of functions is so limited.



A command is an instruction given by a user to tell a computer to do something, for example, executing a single program or a group of linked programs.



A program is a sequence of instructions (i.e. commands) that are given to a computer and understandable by the computer's central processing unit (CPU). these instructions indicates which operations the computer should perform on a set of data.



Having said that, functions are logical subset of the program. Calling one is entirely within your process. The command is a program (or a shell built-in) can be executed from the command shell. The command implements functions which perform a task. The opposite is not correct.






share|improve this answer


















  • 10




    "a function returns a single value, and does not output anything" -- well, yeah, in the mathematical sense maybe. But in imperative programming languages, it's really common for "function" to mean just a subroutine, one that could do anything. And shell functions in particular may very well have output or other side effects, since the return value of functions is so limited.
    – ilkkachu
    Sep 13 at 11:51










  • @ilkkachu. Thank you. I have updated the answer. Please feel free to revise ;-)
    – Goro
    Sep 13 at 11:56






  • 3




    I think these definitions are from a programming-language context, not a shell context. Yes, I know the shell language is a programming language, but its idea of a "function" is quite different to the mathematical or computer-science definition - in shell, all commands (whether builtins, functions, aliases, programs or scripts) act alike, and are simply different kinds of implementation.
    – Toby Speight
    Sep 13 at 16:51







  • 1




    ...*mostly* alike; builtins can change the state of the shell itself, whereas external programs can't call chdir() or setenv() in the shell that is, to them, a distinct parent process.
    – Charles Duffy
    Sep 13 at 17:51














up vote
7
down vote













The definition of a function is returning single values, and does not output anything. Shell functions in particular may very well and could have an output or other side effects, since the return value of functions is so limited.



A command is an instruction given by a user to tell a computer to do something, for example, executing a single program or a group of linked programs.



A program is a sequence of instructions (i.e. commands) that are given to a computer and understandable by the computer's central processing unit (CPU). these instructions indicates which operations the computer should perform on a set of data.



Having said that, functions are logical subset of the program. Calling one is entirely within your process. The command is a program (or a shell built-in) can be executed from the command shell. The command implements functions which perform a task. The opposite is not correct.






share|improve this answer


















  • 10




    "a function returns a single value, and does not output anything" -- well, yeah, in the mathematical sense maybe. But in imperative programming languages, it's really common for "function" to mean just a subroutine, one that could do anything. And shell functions in particular may very well have output or other side effects, since the return value of functions is so limited.
    – ilkkachu
    Sep 13 at 11:51










  • @ilkkachu. Thank you. I have updated the answer. Please feel free to revise ;-)
    – Goro
    Sep 13 at 11:56






  • 3




    I think these definitions are from a programming-language context, not a shell context. Yes, I know the shell language is a programming language, but its idea of a "function" is quite different to the mathematical or computer-science definition - in shell, all commands (whether builtins, functions, aliases, programs or scripts) act alike, and are simply different kinds of implementation.
    – Toby Speight
    Sep 13 at 16:51







  • 1




    ...*mostly* alike; builtins can change the state of the shell itself, whereas external programs can't call chdir() or setenv() in the shell that is, to them, a distinct parent process.
    – Charles Duffy
    Sep 13 at 17:51












up vote
7
down vote










up vote
7
down vote









The definition of a function is returning single values, and does not output anything. Shell functions in particular may very well and could have an output or other side effects, since the return value of functions is so limited.



A command is an instruction given by a user to tell a computer to do something, for example, executing a single program or a group of linked programs.



A program is a sequence of instructions (i.e. commands) that are given to a computer and understandable by the computer's central processing unit (CPU). these instructions indicates which operations the computer should perform on a set of data.



Having said that, functions are logical subset of the program. Calling one is entirely within your process. The command is a program (or a shell built-in) can be executed from the command shell. The command implements functions which perform a task. The opposite is not correct.






share|improve this answer














The definition of a function is returning single values, and does not output anything. Shell functions in particular may very well and could have an output or other side effects, since the return value of functions is so limited.



A command is an instruction given by a user to tell a computer to do something, for example, executing a single program or a group of linked programs.



A program is a sequence of instructions (i.e. commands) that are given to a computer and understandable by the computer's central processing unit (CPU). these instructions indicates which operations the computer should perform on a set of data.



Having said that, functions are logical subset of the program. Calling one is entirely within your process. The command is a program (or a shell built-in) can be executed from the command shell. The command implements functions which perform a task. The opposite is not correct.







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 13 at 16:59

























answered Sep 13 at 11:20









Goro

5,47052460




5,47052460







  • 10




    "a function returns a single value, and does not output anything" -- well, yeah, in the mathematical sense maybe. But in imperative programming languages, it's really common for "function" to mean just a subroutine, one that could do anything. And shell functions in particular may very well have output or other side effects, since the return value of functions is so limited.
    – ilkkachu
    Sep 13 at 11:51










  • @ilkkachu. Thank you. I have updated the answer. Please feel free to revise ;-)
    – Goro
    Sep 13 at 11:56






  • 3




    I think these definitions are from a programming-language context, not a shell context. Yes, I know the shell language is a programming language, but its idea of a "function" is quite different to the mathematical or computer-science definition - in shell, all commands (whether builtins, functions, aliases, programs or scripts) act alike, and are simply different kinds of implementation.
    – Toby Speight
    Sep 13 at 16:51







  • 1




    ...*mostly* alike; builtins can change the state of the shell itself, whereas external programs can't call chdir() or setenv() in the shell that is, to them, a distinct parent process.
    – Charles Duffy
    Sep 13 at 17:51












  • 10




    "a function returns a single value, and does not output anything" -- well, yeah, in the mathematical sense maybe. But in imperative programming languages, it's really common for "function" to mean just a subroutine, one that could do anything. And shell functions in particular may very well have output or other side effects, since the return value of functions is so limited.
    – ilkkachu
    Sep 13 at 11:51










  • @ilkkachu. Thank you. I have updated the answer. Please feel free to revise ;-)
    – Goro
    Sep 13 at 11:56






  • 3




    I think these definitions are from a programming-language context, not a shell context. Yes, I know the shell language is a programming language, but its idea of a "function" is quite different to the mathematical or computer-science definition - in shell, all commands (whether builtins, functions, aliases, programs or scripts) act alike, and are simply different kinds of implementation.
    – Toby Speight
    Sep 13 at 16:51







  • 1




    ...*mostly* alike; builtins can change the state of the shell itself, whereas external programs can't call chdir() or setenv() in the shell that is, to them, a distinct parent process.
    – Charles Duffy
    Sep 13 at 17:51







10




10




"a function returns a single value, and does not output anything" -- well, yeah, in the mathematical sense maybe. But in imperative programming languages, it's really common for "function" to mean just a subroutine, one that could do anything. And shell functions in particular may very well have output or other side effects, since the return value of functions is so limited.
– ilkkachu
Sep 13 at 11:51




"a function returns a single value, and does not output anything" -- well, yeah, in the mathematical sense maybe. But in imperative programming languages, it's really common for "function" to mean just a subroutine, one that could do anything. And shell functions in particular may very well have output or other side effects, since the return value of functions is so limited.
– ilkkachu
Sep 13 at 11:51












@ilkkachu. Thank you. I have updated the answer. Please feel free to revise ;-)
– Goro
Sep 13 at 11:56




@ilkkachu. Thank you. I have updated the answer. Please feel free to revise ;-)
– Goro
Sep 13 at 11:56




3




3




I think these definitions are from a programming-language context, not a shell context. Yes, I know the shell language is a programming language, but its idea of a "function" is quite different to the mathematical or computer-science definition - in shell, all commands (whether builtins, functions, aliases, programs or scripts) act alike, and are simply different kinds of implementation.
– Toby Speight
Sep 13 at 16:51





I think these definitions are from a programming-language context, not a shell context. Yes, I know the shell language is a programming language, but its idea of a "function" is quite different to the mathematical or computer-science definition - in shell, all commands (whether builtins, functions, aliases, programs or scripts) act alike, and are simply different kinds of implementation.
– Toby Speight
Sep 13 at 16:51





1




1




...*mostly* alike; builtins can change the state of the shell itself, whereas external programs can't call chdir() or setenv() in the shell that is, to them, a distinct parent process.
– Charles Duffy
Sep 13 at 17:51




...*mostly* alike; builtins can change the state of the shell itself, whereas external programs can't call chdir() or setenv() in the shell that is, to them, a distinct parent process.
– Charles Duffy
Sep 13 at 17:51










up vote
1
down vote














I would like to know whether the commands that we call in the shell are functions or programs?




Yes.



Specifically, when you type in some text and press enter, the shell must determine whether it's:



  1. an alias,

  2. a function,

  3. a built-in command,

  4. an executable file.





share|improve this answer


















  • 1




    @jlliagre thanks. Will edit the answer.
    – RonJohn
    Sep 13 at 17:36














up vote
1
down vote














I would like to know whether the commands that we call in the shell are functions or programs?




Yes.



Specifically, when you type in some text and press enter, the shell must determine whether it's:



  1. an alias,

  2. a function,

  3. a built-in command,

  4. an executable file.





share|improve this answer


















  • 1




    @jlliagre thanks. Will edit the answer.
    – RonJohn
    Sep 13 at 17:36












up vote
1
down vote










up vote
1
down vote










I would like to know whether the commands that we call in the shell are functions or programs?




Yes.



Specifically, when you type in some text and press enter, the shell must determine whether it's:



  1. an alias,

  2. a function,

  3. a built-in command,

  4. an executable file.





share|improve this answer















I would like to know whether the commands that we call in the shell are functions or programs?




Yes.



Specifically, when you type in some text and press enter, the shell must determine whether it's:



  1. an alias,

  2. a function,

  3. a built-in command,

  4. an executable file.






share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 13 at 17:36

























answered Sep 13 at 16:43









RonJohn

500214




500214







  • 1




    @jlliagre thanks. Will edit the answer.
    – RonJohn
    Sep 13 at 17:36












  • 1




    @jlliagre thanks. Will edit the answer.
    – RonJohn
    Sep 13 at 17:36







1




1




@jlliagre thanks. Will edit the answer.
– RonJohn
Sep 13 at 17:36




@jlliagre thanks. Will edit the answer.
– RonJohn
Sep 13 at 17:36

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468764%2fwhat-is-the-difference-between-the-terms-program-command-and-function-in%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay