\"
\" Copyright (c) 2006-2019
\"      Jeffrey Allen Neitzel <jan (at) etsh (dot) nl>.
\"      All rights reserved.
\"
\" Redistribution and use in source and binary forms, with or without
\" modification, are permitted provided that the following conditions
\" are met:
\" 1. Redistributions of source code must retain the above copyright
\"    notice, this list of conditions and the following disclaimer.
\" 2. Redistributions in binary form must reproduce the above copyright
\"    notice, this list of conditions and the following disclaimer in the
\"    documentation and/or other materials provided with the distribution.
\"
\" THIS SOFTWARE IS PROVIDED BY JEFFREY ALLEN NEITZEL ``AS IS'', AND ANY
\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\" DISCLAIMED.  IN NO EVENT SHALL JEFFREY ALLEN NEITZEL BE LIABLE FOR ANY
\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\"
\"      @(#)$Id: glob.1,v 1.5 2019/03/14 08:50:46 jneitzel Exp $
\"
\"      Derived from:
\"              - V6 UNIX /usr/[doc/]man/man1/sh.1
\"              - V6 UNIX /usr/[doc/]man/man8/glob.8
\"
\" Copyright (C) Caldera International Inc.  2001-2002.  All rights reserved.
\"
\" Redistribution and use in source and binary forms, with or without
\" modification, are permitted provided that the following conditions
\" are met:
\" 1. Redistributions of source code and documentation must retain the above
\"    copyright notice, this list of conditions and the following disclaimer.
\" 2. Redistributions in binary form must reproduce the above copyright
\"    notice, this list of conditions and the following disclaimer in the
\"    documentation and/or other materials provided with the distribution.
\" 3. All advertising materials mentioning features or use of this software
\"    must display the following acknowledgement:
\"      This product includes software developed or owned by Caldera
\"      International, Inc.
\" 4. Neither the name of Caldera International, Inc. nor the names of other
\"    contributors may be used to endorse or promote products derived from
\"    this software without specific prior written permission.
\"
\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT,
\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\" POSSIBILITY OF SUCH DAMAGE.
\"
\" Includes public domain content derived from:
\"              - /usr/src/bin/ksh/sh.1
\"                      $OpenBSD: sh.1,v 1.91 2011/09/03 22:59:08 jmc Exp $
\"
TH GLOB 1 "March 28, 2019" "etsh-5.4.0" "General Commands Manual"
SH NAME
glob \- global command (file name generation)
SH SYNOPSIS
B glob
\fIcommand\fR [\fIarg ...\fR]
SH DESCRIPTION
B Glob
is a port of the global command from Version 6 (V6) UNIX.
It is passed an argument list by
IR tsh (1)
which contains one or more unquoted
I "pattern characters"
(\fB*\fR, \fB?\fR, \fB[\fR)
and performs the actions described below
on behalf of the shell.
PP
B Glob
attempts to generate file-name arguments which match
the given pattern arguments.
The name of the specified
I command
may also be given as a pattern.
The meaning of each pattern character is as follows:
IP o 4
The \fB*\fR character in a pattern matches any string of
characters in a file name (including the null string).
IP o
The \fB?\fR character in a pattern matches any single character
in a file name.
IP o
The \fB[...]\fR brackets in a pattern specifies a class of characters
which matches any single file-name character in the class.
Within the brackets,
each character is taken to be a member of the class.
A pair of characters separated by an unquoted \fB\-\fR specifies
the class as a range which matches each character lexically
between the first and second member of the pair, inclusive.
A \fB\-\fR matches itself when quoted or when first or last
in the class.
PP
Any other character in a pattern matches itself in a file name.
PP
Notice that the `.' character at the beginning of a file name,
or immediately following a `/',
is always special in that it must be matched explicitly.
The same is true of the `/' character itself.
PP
If the pattern contains no `/' characters,
the current directory is always used.
Otherwise,
the specified directory is the one obtained by taking the pattern
up to the last `/' before the first unquoted \fB*\fR, \fB?\fR, or \fB[\fR.
The matching process matches the remainder of the pattern
after this `/' against the files in the specified directory.
PP
If the argument contains no unquoted pattern characters,
B glob
uses it as is.
Otherwise,
glob searches for file names in the current
(or specified) directory which match the pattern.
It then sorts them in ascending ASCII order,
and the new sequence of arguments replaces the given pattern.
The same process is carried out for each of the given arguments;
the resulting lists are
I not
merged.
Finally,
glob attempts to execute the command
with the resulting argument list.
SH "EXIT STATUS"
If
B glob
detects an error,
it prints an appropriate diagnostic
and exits with a non-zero status.
Otherwise,
the exit status is that
of the executed command.
SH ENVIRONMENT
Notice that the concept of `user environment'
was not defined in Version 6 (V6) UNIX.
Thus,
use of the following environment variables
by this port of the global command
is an enhancement:
TP
B EXECSHELL
If set to a non-empty string,
the value of this variable is taken as the
path name of the shell which is invoked to
execute the specified command when it does not
begin with the proper magic number
or a `#!shell' sequence.
TP
B PATH
If set to a non-empty string,
the value of this variable is taken as the
sequence of directories which is used to
search for the specified command.
Notice that the
global command from Version 6 (V6) UNIX
always used the equivalent of `.:/bin:/usr/bin',
not PATH.
SH "SEE ALSO"
tsh(1)
PP
Etsh home page:
https://etsh.nl/
SH HISTORY
A
B glob
command
appeared as
I /etc/glob
in Version 1 (V1) UNIX.
SH AUTHORS
This port of the
B glob
command is derived from
Version 6 (V6) UNIX /usr/source/s1/glob.c.
It was written by Ken Thompson of Bell Labs.
Jeffrey Allen Neitzel
RI < [email protected] >
ported and maintains it as
IR glob (1).
SH LICENSE
See either the LICENSE file which is distributed with
B etsh
or
https://etsh.nl/license/
for full details.