Skip to main content
added 6 characters in body
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k

The yash shell does have, and does use, a built-in version of printf (and other utilities). It just happens to be very pedantically POSIX compliant in the way it formulates the result of the command -v and type commands.

As mosvy comments, the POSIX standard requires that a regular built-in command be available as an external command in $PATH for the built-in version of the command to be executed.

This is the relevant text from the standard:

Command Search and Execution

If a simple command results in a command name and an optional list of arguments, the following actions shall be performed:

  1. If the command name does not contain any <slash> characters, the first successful step in the following sequence shall occur:
  • a. If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked.
 [...] 
  • e. Otherwise, the command shall be searched for using the PATH environment variable as described in XBD Environment Variables : - i. If the search is successful: - a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. - b. Otherwise, the shell executes the utility in a separate utility environment [...]
    [...]
    • ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.
  1. If the command name contains at least one <slash>, [...]

This means that the output of command -v printf signifies that the printf command was found in the search path, while the output of type printf adds to this that the command is a regular built-in.

Since the printf command was found in the search path, and since it's a regular built-in in the shell, yash will call its built-in version of the command. If the printf was not found in the path, and if the yash shell was running in POSIX-ly correct mode, an error would have been generated instead.

yash prides itself on being a very POSIX compliant shell, and this is also true if we look at what POSIX says about command -v:

-v

Write a string to standard output that indicates the pathname or command that will be used by the shell, in the current shell execution environment (see Shell Execution Environment), to invoke command_name, but do not invoke command_name.

  • Utilities, regular built-in utilities, command_names including a <slash> character, and any implementation-defined functions that are found using the PATH variable (as described in Command Search and Execution), shall be written as absolute pathnames.

The yash shell does have, and does use, a built-in version of printf (and other utilities). It just happens to be very pedantically POSIX compliant in the way it formulates the result of the command -v and type commands.

As mosvy comments, the POSIX standard requires that a regular built-in command be available as an external command in $PATH for the built-in version of the command to be executed.

This is the relevant text from the standard:

Command Search and Execution

If a simple command results in a command name and an optional list of arguments, the following actions shall be performed:

  1. If the command name does not contain any <slash> characters, the first successful step in the following sequence shall occur:
  • a. If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked.
 [...] 
  • e. Otherwise, the command shall be searched for using the PATH environment variable as described in XBD Environment Variables : - i. If the search is successful: - a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. - b. Otherwise, the shell executes the utility in a separate utility environment [...]
    [...]
    • ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.
  1. If the command name contains at least one , [...]

This means that the output of command -v printf signifies that the printf command was found in the search path, while the output of type printf adds to this that the command is a regular built-in.

Since the printf command was found in the search path, and since it's a regular built-in in the shell, yash will call its built-in version of the command. If the printf was not found in the path, and if the yash shell was running in POSIX-ly correct mode, an error would have been generated instead.

yash prides itself on being a very POSIX compliant shell, and this is also true if we look at what POSIX says about command -v:

-v

Write a string to standard output that indicates the pathname or command that will be used by the shell, in the current shell execution environment (see Shell Execution Environment), to invoke command_name, but do not invoke command_name.

  • Utilities, regular built-in utilities, command_names including a <slash> character, and any implementation-defined functions that are found using the PATH variable (as described in Command Search and Execution), shall be written as absolute pathnames.

The yash shell does have, and does use, a built-in version of printf (and other utilities). It just happens to be very pedantically POSIX compliant in the way it formulates the result of the command -v and type commands.

As mosvy comments, the POSIX standard requires that a regular built-in command be available as an external command in $PATH for the built-in version of the command to be executed.

This is the relevant text from the standard:

Command Search and Execution

If a simple command results in a command name and an optional list of arguments, the following actions shall be performed:

  1. If the command name does not contain any <slash> characters, the first successful step in the following sequence shall occur:
  • a. If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked.
 [...] 
  • e. Otherwise, the command shall be searched for using the PATH environment variable as described in XBD Environment Variables : - i. If the search is successful: - a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. - b. Otherwise, the shell executes the utility in a separate utility environment [...]
    [...]
    • ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.
  1. If the command name contains at least one <slash>, [...]

This means that the output of command -v printf signifies that the printf command was found in the search path, while the output of type printf adds to this that the command is a regular built-in.

Since the printf command was found in the search path, and since it's a regular built-in in the shell, yash will call its built-in version of the command. If the printf was not found in the path, and if the yash shell was running in POSIX-ly correct mode, an error would have been generated instead.

yash prides itself on being a very POSIX compliant shell, and this is also true if we look at what POSIX says about command -v:

-v

Write a string to standard output that indicates the pathname or command that will be used by the shell, in the current shell execution environment (see Shell Execution Environment), to invoke command_name, but do not invoke command_name.

  • Utilities, regular built-in utilities, command_names including a <slash> character, and any implementation-defined functions that are found using the PATH variable (as described in Command Search and Execution), shall be written as absolute pathnames.
fix angle-brackets to not disappear
Source Link
dave_thompson_085
  • 4.5k
  • 1
  • 19
  • 16

The yash shell does have, and does use, a built-in version of printf (and other utilities). It just happens to be very pedantically POSIX compliant in the way it formulates the result of the command -v and type commands.

As mosvy comments, the POSIX standard requires that a regular built-in command be available as an external command in $PATH for the built-in version of the command to be executed.

This is the relevant text from the standard:

Command Search and Execution

If a simple command results in a command name and an optional list of arguments, the following actions shall be performed:

  1. If the command name does not contain any characters<slash> characters, the first successful step in the following sequence shall occur:
  • a. If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked.
 [...] 
  • e. Otherwise, the command shall be searched for using the PATH environment variable as described in XBD Environment Variables : - i. If the search is successful: - a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. - b. Otherwise, the shell executes the utility in a separate utility environment [...]
    [...]
    • ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.
  1. If the command name contains at least one , [...]

This means that the output of command -v printf signifies that the printf command was found in the search path, while the output of type printf adds to this that the command is a regular built-in.

Since the printf command was found in the search path, and since it's a regular built-in in the shell, yash will call its built-in version of the command. If the printf was not found in the path, and if the yash shell was running in POSIX-ly correct mode, an error would have been generated instead.

yash prides itself on being a very POSIX compliant shell, and this is also true if we look at what POSIX says about command -v:

-v

Write a string to standard output that indicates the pathname or command that will be used by the shell, in the current shell execution environment (see Shell Execution Environment), to invoke command_name, but do not invoke command_name.

  • Utilities, regular built-in utilities, command_names including a <slash> character, and any implementation-defined functions that are found using the PATH variable (as described in Command Search and Execution), shall be written as absolute pathnames.

The yash shell does have, and does use, a built-in version of printf (and other utilities). It just happens to be very pedantically POSIX compliant in the way it formulates the result of the command -v and type commands.

As mosvy comments, the POSIX standard requires that a regular built-in command be available as an external command in $PATH for the built-in version of the command to be executed.

This is the relevant text from the standard:

Command Search and Execution

If a simple command results in a command name and an optional list of arguments, the following actions shall be performed:

  1. If the command name does not contain any characters, the first successful step in the following sequence shall occur:
  • a. If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked.
 [...] 
  • e. Otherwise, the command shall be searched for using the PATH environment variable as described in XBD Environment Variables : - i. If the search is successful: - a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. - b. Otherwise, the shell executes the utility in a separate utility environment [...]
    [...]
    • ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.
  1. If the command name contains at least one , [...]

This means that the output of command -v printf signifies that the printf command was found in the search path, while the output of type printf adds to this that the command is a regular built-in.

Since the printf command was found in the search path, and since it's a regular built-in in the shell, yash will call its built-in version of the command. If the printf was not found in the path, and if the yash shell was running in POSIX-ly correct mode, an error would have been generated instead.

yash prides itself on being a very POSIX compliant shell, and this is also true if we look at what POSIX says about command -v:

-v

Write a string to standard output that indicates the pathname or command that will be used by the shell, in the current shell execution environment (see Shell Execution Environment), to invoke command_name, but do not invoke command_name.

  • Utilities, regular built-in utilities, command_names including a <slash> character, and any implementation-defined functions that are found using the PATH variable (as described in Command Search and Execution), shall be written as absolute pathnames.

The yash shell does have, and does use, a built-in version of printf (and other utilities). It just happens to be very pedantically POSIX compliant in the way it formulates the result of the command -v and type commands.

As mosvy comments, the POSIX standard requires that a regular built-in command be available as an external command in $PATH for the built-in version of the command to be executed.

This is the relevant text from the standard:

Command Search and Execution

If a simple command results in a command name and an optional list of arguments, the following actions shall be performed:

  1. If the command name does not contain any <slash> characters, the first successful step in the following sequence shall occur:
  • a. If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked.
 [...] 
  • e. Otherwise, the command shall be searched for using the PATH environment variable as described in XBD Environment Variables : - i. If the search is successful: - a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. - b. Otherwise, the shell executes the utility in a separate utility environment [...]
    [...]
    • ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.
  1. If the command name contains at least one , [...]

This means that the output of command -v printf signifies that the printf command was found in the search path, while the output of type printf adds to this that the command is a regular built-in.

Since the printf command was found in the search path, and since it's a regular built-in in the shell, yash will call its built-in version of the command. If the printf was not found in the path, and if the yash shell was running in POSIX-ly correct mode, an error would have been generated instead.

yash prides itself on being a very POSIX compliant shell, and this is also true if we look at what POSIX says about command -v:

-v

Write a string to standard output that indicates the pathname or command that will be used by the shell, in the current shell execution environment (see Shell Execution Environment), to invoke command_name, but do not invoke command_name.

  • Utilities, regular built-in utilities, command_names including a <slash> character, and any implementation-defined functions that are found using the PATH variable (as described in Command Search and Execution), shall be written as absolute pathnames.
Better match for the spec indentation format.
Source Link
user232326
user232326

Command Search and Execution

If a simple command results in a command name and an optional list of arguments, the following actions shall be performed:

 
  1. If the command name does not contain any <slash> characters characters, the first successful step in the following sequence shall occur:

a. [...b, c, d... (these handle special built-ins, two sets of listed utilities (some of which yash refers to as "semi-special built-ins"), and shell functions]

 

e. Otherwise, the command shall be searched for using the PATH environment variable [...]

  • a. If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked.

i. If the search is successful: a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. [...]

 

[...]

 [...] 

ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.

  • e. Otherwise, the command shall be searched for using the PATH environment variable as described in XBD Environment Variables : - i. If the search is successful: - a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. - b. Otherwise, the shell executes the utility in a separate utility environment [...]
    [...]
    • ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.
  1. If the command name contains at least one , [...]

If a simple command results in a command name and an optional list of arguments, the following actions shall be performed:

  1. If the command name does not contain any <slash> characters, the first successful step in the following sequence shall occur:

a. [...b, c, d... (these handle special built-ins, two sets of listed utilities (some of which yash refers to as "semi-special built-ins"), and shell functions]

e. Otherwise, the command shall be searched for using the PATH environment variable [...]

i. If the search is successful: a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. [...]

[...]

ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.

Command Search and Execution

If a simple command results in a command name and an optional list of arguments, the following actions shall be performed:

 
  1. If the command name does not contain any characters, the first successful step in the following sequence shall occur:
 
  • a. If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked.
 
 [...] 
  • e. Otherwise, the command shall be searched for using the PATH environment variable as described in XBD Environment Variables : - i. If the search is successful: - a. If the system has implemented the utility as a regular built-in or as a shell function, it shall be invoked at this point in the path search. - b. Otherwise, the shell executes the utility in a separate utility environment [...]
    [...]
    • ii. If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message.
  1. If the command name contains at least one , [...]
added 11 characters in body
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k
Loading
deleted 12 characters in body
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k
Loading
added 151 characters in body
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k
Loading
added 8 characters in body
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k
Loading
Source Link
Kusalananda
  • 356.6k
  • 42
  • 739
  • 1.1k
Loading