[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shouldn't "type" and "command" complain if there are no parameters?

From: Victor Engmark
Subject: Re: Shouldn't "type" and "command" complain if there are no parameters?
Date: Thu, 26 Apr 2012 07:48:47 +0200

On Thu, Apr 26, 2012 at 3:50 AM, Linda Walsh <address@hidden> wrote:

> Victor Engmark wrote:
>> Re-post from <http://unix.stackexchange.**com/questions/36752/why-are-**
>> parameters-to-bashs-command-**and-type-optional<http://unix.stackexchange.com/questions/36752/why-are-parameters-to-bashs-command-and-type-optional>
>> >:
>> [T]hese commands print nothing and return exit code 0 if no parameters
>> are provided. But [...] `help command` and `help type` both state that at
>> least one parameter is mandatory. Is this a bug, a feature, or did I
>> misunderstand something?
> command executes the named argument as a command.
> It is perfectly valid to type in nothing at the command line and expect
> no error.

Actually, if you type in a command, and then press Enter more than once,
the exit code is *kept*, as if you had pressed Enter only once. So pressing
Enter on an empty command line is *not* the same as saying `:`, or `true`.

A similar argument like can be proposed for type.
> You give it nothing as input, why would you expect output?

The issue is rather that the synopsis is *inconsistent* with the
functioning of `type` and `command`. For example, the `watch` command
requires a command string as its last parameter, and without it, it prints
its own synopsis and returns with exit code 1, as expected.

My suggestion is simply that unless someone can show that somehow the
synopsis *is* consistent with the functioning of these builtins, the
synopsis should be corrected *or* the functioning of these commands should
be changed, in order to be consistent with most other *nix tools.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]