command: Rename -p/--path flag to -s/--search

This commit is contained in:
Kevin Ballard 2014-07-10 19:16:32 -07:00
parent cfa13ed84c
commit 72e8489d50
3 changed files with 10 additions and 7 deletions

View file

@ -1067,7 +1067,7 @@ static int builtin_command(parser_t &parser, wchar_t **argv)
static const struct woption
long_options[] =
{
{ L"path", no_argument, 0, 'p' },
{ L"search", no_argument, 0, 's' },
{ L"help", no_argument, 0, 'h' },
{ 0, 0, 0, 0 }
};
@ -1078,7 +1078,7 @@ static int builtin_command(parser_t &parser, wchar_t **argv)
int opt = wgetopt_long(argc,
argv,
L"ph",
L"svh",
long_options,
&opt_index);
if (opt == -1)
@ -1100,7 +1100,8 @@ static int builtin_command(parser_t &parser, wchar_t **argv)
builtin_print_help(parser, argv[0], stdout_buffer);
return STATUS_BUILTIN_OK;
case 'p':
case 's':
case 'v':
print_path=1;
break;

View file

@ -9,12 +9,14 @@
The following options are available:
- \c -h or \c --help prints help and then exits.
- \c -p or \c --path returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the <tt>$PATH</tt>.
- \c -s or \c --search returns the name of the disk file that would be executed, or nothing if no file with the specified name could be found in the <tt>$PATH</tt>.
With the \c -p option, \c command treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found.
With the \c -s option, \c command treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found.
For basic compatibility with POSIX <tt>command</tt>, the \c -v flag is recognized as an alias for <tt>-s</tt>.
\subsection command-example Examples
<tt>command ls</tt> causes fish to execute the \c ls program, even if an 'ls' function exists.
<tt>command -p ls</tt> returns the path to the \c ls program.
<tt>command -s ls</tt> returns the path to the \c ls program.

View file

@ -96,7 +96,7 @@ function type --description "Print the type of a command"
set -l paths
if test $multi != yes
set paths (command -p $i)
set paths (command -s $i)
else
set paths (which -a $i ^/dev/null)
end