portsnap

jb jb.1234abcd at gmail.com
Mon Nov 19 22:06:02 UTC 2012


Robert Bonomi <bonomi <at> mail.r-bonomi.com> writes:

> 
> > From owner-freebsd-questions <at> freebsd.org  Mon Nov 19 14:15:23 2012
> > To: freebsd-questions <at> freebsd.org
> > From: jb <jb.1234abcd <at> gmail.com>
> > Subject: Re: portsnap
> > Date: Mon, 19 Nov 2012 20:13:45 +0000 (UTC)
> >
> > RW <rwmaillists <at> googlemail.com> writes:
> >
> > >
> > > On Mon, 19 Nov 2012 16:10:48 +0000 (UTC) jb wrote:
> > >
> > > > > You gave portsnap two commands - one succeeded and the other 
> > > > > failed.
> >
> > Nope. I gave ONE command: 'portsnap fetch update'.
> 
> FALSE TO FACT.

No way.
UNIX command (on a command line, also called CLI), is anything between prompt
(e.g. $) and ENTER, that is in general:
$ command <option> <option>
and this is how shell interprets it.
There are simple commands as above, and command constructs as pipeline and 
lists, e.g.
$ command <options> | command <options> ; command1; command2
but that does not change the meaning of how they are interpreted as commands.

You got confused by portsnap(8) vocabulary, which is misleading:
SYNOPSIS
     portsnap [-I] [-d workdir] [-f conffile] [-k KEY] [-l descfile]
              [-p portsdir] [-s server] command ... [path]
...
COMMANDS
     The command can be any one of the following:

     fetch        Fetch a compressed snapshot of the ports tree, or update the
...

The word "command" in SYNOPSIS is very unfortunate, outright wrong because
misleading - it represents an option or a parameter to a command "portsnap".
This is how any command line parser/editor processes the entire entry.
No magic here.

This should explain your confusion in the rest of your post.

> ...


> > In general, if I wanted to check for command completion code, which is 
> > quite common in UNIX CLI or scripting env, it would make a lot of 
> > difference if a command failed half way in both cases:
> > 'portsnap fetch update; check-completion-code'
> > and 'portsnap fetch; check-completion-code; portsnap update; 
> > check-completion-code'
> 
> 'portsnap fetch update' is the EXACT equivalent of:
>   'portsnap fetch && portsnap update; `check-completion-code'`

No, it is not.

Your CLI command line above is an example of a list (see bash(1)): 
...
  Lists
       A list is a sequence of one or more pipelines separated by one  of  the
       operators ;, &, &&, or ||, and optionally terminated by one of ;, &, or
       <newline>.
...

In other words, it is a CLI command that is a composition of INDEPENDENT
commands, here logically linked with "&&'.

It is not the same as your list - the difference is, once again, that when I
enter:
$ portsnap fetch update
this represents a CLI command, just one command with two options or params,
as understood in UNIX and as explained at the very beginning of this post,
regardless of how it is going to be executed internally (with subtasks "fetch"
and "update" playing only internal and logical role in the context of that
command's execution). It follows, that the completion code is of that one CLI
command, and not a logical "&&" result of multiple commands in a list.

jb




More information about the freebsd-questions mailing list