The below works without any external processes:
if ! command -v perl >/dev/null 2>&1; then
# something wrong
fi
Note that a builtin, function or alias is also considered valid here.
Traps are not executed while the shell is waiting for a foreground process to terminate, and a successful reboot(8) never terminates (it eventually calls reboot(2) which does not return control).
There is no way to access si_code or any other siginfo_t member in a shell script.
Variables without a $ in arithmetic are documented behaviour (see Arithmetic Expansion in sh(1)) and required by POSIX.
Also, variables can be assigned new values. For example, a variable can be incremented without mentioning its name twice:
: $((very_long_name += 1))
The ++ and --...
The extra $(( )) may still be useful because it removes the space that %e inserts before days less than 10.
The change to 09 is a deliberate change to sh in 9.0.
You are right. This is because utmp was replaced with utmpx and various limits were increased at that time.
The limit in 8.x is in the kernel but is only there because of utmp and its importance for tracking sessions.
[ is expanded like any other simple command. The three tests in your first function are not all expanded the same but all are valid tests returning false. The third test in your second function causes a test(1) syntax error because "$@" expands to nothing at all if there are no positional...
I recommend not using -a, -o and parentheses at all, but the construct
[ ! "$string1" -a "$string2" ]
is particularly nasty. Some test implementations such as the builtins in bash and FreeBSD sh consider -a and -o "binary primaries" (POSIX SUSv4 XCU 4 Utilities test) and obey the rule for 4...
In the particular case that this 32 bit machine has a Pentium or higher x86 CPU, the CPU provides a 64-bit atomic compare-and-exchange operation CMPXCHG8B. The PAE kernel uses this instruction, see src/sys/i386/include/pmap.h and look for atomic_cmpset_64. This operation is however not generally...
The wildcards are expanded by the shell, not ls. Therefore replace things like
`ls /var/log/system*`
by simply
/var/log/system*
The shell will not split the results of pathname generation again.
Anything can be piped but it will run in a subshell environment so that commands like trap will not print what you may expect. (POSIX allows but does not require this.) In our sh, you can do
traps=$(trap)
and it will return the parent shell environment's traps; this commonly works but is not...
You cannot pipe the output of jobs to something because sh and tcsh always run the left-hand side of a pipe in a subshell environment with its own job list that starts off empty. PR bin/34811 asks for this to be changed in sh but this is unlikely to be in 9.0.
In sh you can still get at the...
expl's answer is incorrect, ipcs applies to System V IPC (also called XSI IPC) only, semget/shmget/msgget.
For sem_open, the answer depends on the version of FreeBSD (more precisely, the API you compile against, so running on 9.x a binary compiled on 8.x will give the 8.x behaviour).
In...
Although various shells such as bash, ksh93 and zsh handle this in a more expected manner, FreeBSD sh follows a literal reading of POSIX here. Variable assignments (before a command word or if there is no command word at all) are expanded differently from other words in a simple command...
Traps seem unnecessary here, what you need is sh(1)'s ability to wait for a specific process. For example:
scp ... &
scppid=$!
ping ... &
pingpid=$!
wait $scppid
kill $pingpid
wait $pingpid
If you combine this with traps, take care that wait terminates prematurely if a trap occurs.
Regarding terminology, the API you are asking about is generally known as "System V message queues" or "XSI message queues". "POSIX message queues" use mq_open and related functions. Another option is Unix domain sockets.
You are right that the "identifier" is a system-wide number persistent...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.