From 0c23741f858b896db49147a4c0fe17ec48db3c90 Mon Sep 17 00:00:00 2001
From: dtb
Don't use _code(`echo(1)'), use _code(`printf(1)').
@@ -104,6 +105,73 @@ A traditional _code(`ed(1)') implementation is in plan9ports.
I'm pretty sure some later UNIX-based OSes doubled the _code(`ed(1)') buffers, there's pretty much no downside to doing so in the modern era but it should be very easy to do yourself if it hasn't already been done (just double some of the array sizes in the beginning of _code(`ed.c')).
+_code(`true(1)') is a tool that only quits silently with an exit status of 0.
+Similarly, _code(`false(1)') is a tool that only quits silently with an exit status of 1.
+Recognizing arguments, printing to standard output, reading from standard input, or otherwise exiting with any other status of 0, is a violation of the POSIX specification for _code(`true(1)').
+These utilities find use in shell scripting, which, though extremely relevant to these utilities, is beyond the scope of this article.
+
+Because _code(`true(1)')'s required functionality is so simple a POSIX-compliant implementation is a one-liner in most languages, so long as you're willing to make an exception in your code styling.
+For example, in C:
+
+Because executing an empty shellscript file will in most shells do nothing and return an exit status of 0, technically an empty shellscript file is a POSIX-compliant _code(`true(1)') implementation in 0 bytes.
+This was the _code(`true(1)') implementation on early versions of UNIX, including Research UNIX, System V, and Sun's Solaris, according to both Rob Pike and John Chambers.
+A more explicit implementation also exists in POSIX shell:
+
+This happens to be nearly identical in source to the implementation used by NetBSD.
+
+Python has the same 0 byte _code(`true(1)') implementation feature as most shells.
+Here's _code(`false(1)') in Python rather than _code(`true(1)') to demonstrate how exiting with an arbitrary exit status can be done:
+
+In some shells, _code(`true(1)') is a shell built-in command, so running _code(`true') will run the shell author's implementation of _code(`true(1)') rather than the system implementation.
+
+GNU _code(`true(1)'), from the GNU coreutils, is well known for being a maximalist implementation - it's eighty lines long and directly includes four C header files.
+Their _code(`true.c') is 2.3 kilobytes and parses the arguments _code(`--help') and _code(`--version') (only if either are the first argument to the program).
+The GNU coreutils implementation of _code(`true(1)') is not POSIX compliant.
+
+Unlike _code(`busybox')'s _code(`ed(1)') implementation, its _code(`vi(1)') is very useable.
+_code(`vim(1)') is a popular re-implementation of _code(`vi(1)').
+
+_code(`util-linux') is distributed on all popular Linux distributions and contains utilities users may expect to be already present on their systems, like _code(`more(1)') or _code(`hexdump(1)').
+echo(1)
-
true(1)
+
+
+
+int main(void) { return 0; }
+
+
+#!/bin/sh
+exit 0
+
+
+import sys
+sys.exit(1)
+
+vi
+
+
+util-linux
+
+Advanced Configuration and Power Interface
_code(`envstat(1)') can show the current battery status.
++Install _code(`filesystems/fuse') and _code(`filesystems/fuse-ext2'). +_code(`disklabel(8)') will list ext4 filesystems as of type "Linux Ext2". +Use _code(`fuse-ext2(1)') to mount the filesystem. +
++_code(`fuse-ext2(1)') is spotty in places and may not work correctly. +
++Install _code(`filesystems/fuse') and _code(`filesystems/fuse-exfat'). +Use _code(`mount.exfat') to mount the filesystem (the manual page for which is _code(`mount.exfat-fuse(8)')). +
+Install _code(`security/mozilla-rootcerts-openssl').
++Do not use SSL workarounds like (in the case of git) _code(`GIT_SSL_NO_VERIFY'). +These leave your system open to man-in-the-middle attacks. +
++If using Mullvad, you have to change the shebang on _code(`update-resolv-conf(8)') +(a standalone Bash script included in the OpenVPN configurations from Mullvad, intended to be placed in _code(`/etc/openvpn/')) +from _code(`#!/bin/bash') to _code(`#!/usr/pkg/bin/bash') if using Bash from pkgsrc or another appropriate location if using a different package manager. +
+See _code(`syslogd(8)') and _code(`syslog.conf(5)'), which pertain to system logging.
+Setting _code(`DDB_ONPANIC') (see _code(`options(4)') and _code(`sysctl(8)')) will save a crash dump at _code(`/var/crash') on kernel panic. +
In the context of POSIX and UNIX-like systems, an "on-line" manual is a manual that is accessible via the computer system it documents. @@ -464,73 +599,6 @@ _code(`dm-crypt') will need the UUID of the physical block device while f
_code(`envstat(1)') can show the current battery status.
--Install _code(`filesystems/fuse') and _code(`filesystems/fuse-ext2'). -_code(`disklabel(8)') will list ext4 filesystems as of type "Linux Ext2". -Use _code(`fuse-ext2(1)') to mount the filesystem. -
--_code(`fuse-ext2(1)') is spotty in places and may not work correctly. -
--Install _code(`filesystems/fuse') and _code(`filesystems/fuse-exfat'). -Use _code(`mount.exfat') to mount the filesystem (the manual page for which is _code(`mount.exfat-fuse(8)')). -
-Install _code(`security/mozilla-rootcerts-openssl').
--Do not use SSL workarounds like (in the case of git) _code(`GIT_SSL_NO_VERIFY'). -These leave your system open to man-in-the-middle attacks. -
--If using Mullvad, you have to change the shebang on _code(`update-resolv-conf(8)') -(a standalone Bash script included in the OpenVPN configurations from Mullvad, intended to be placed in _code(`/etc/openvpn/')) -from _code(`#!/bin/bash') to _code(`#!/usr/pkg/bin/bash') if using Bash from pkgsrc or another appropriate location if using a different package manager. -
-See _code(`syslogd(8)') and _code(`syslog.conf(5)'), which pertain to system logging.
-Setting _code(`DDB_ONPANIC') (see _code(`options(4)') and _code(`sysctl(8)')) will save a crash dump at _code(`/var/crash') on kernel panic. -
-Unlike _code(`busybox')'s _code(`ed(1)') implementation, its _code(`vi(1)') is very useable. -_code(`vim(1)') is a popular re-implementation of _code(`vi(1)'). -
Emacs ("editor macros") is a text editor with a very powerful Lisp interpreter included. @@ -624,67 +687,6 @@ Technically _code(`cat(1)') and other UNIX utilities can be used in a hacky way You'd be better off using _code(`ed(1)'); the UX is very similar.
--_code(`true(1)') is a tool that only quits silently with an exit status of 0. -Similarly, _code(`false(1)') is a tool that only quits silently with an exit status of 1. -Recognizing arguments, printing to standard output, reading from standard input, or otherwise exiting with any other status of 0, is a violation of the POSIX specification for _code(`true(1)'). -These utilities find use in shell scripting, which, though extremely relevant to these utilities, is beyond the scope of this article. -
--Because _code(`true(1)')'s required functionality is so simple a POSIX-compliant implementation is a one-liner in most languages, so long as you're willing to make an exception in your code styling. -For example, in C: -
--int main(void) { return 0; } --
-Because executing an empty shellscript file will in most shells do nothing and return an exit status of 0, technically an empty shellscript file is a POSIX-compliant _code(`true(1)') implementation in 0 bytes. -This was the _code(`true(1)') implementation on early versions of UNIX, including Research UNIX, System V, and Sun's Solaris, according to both Rob Pike and John Chambers. -A more explicit implementation also exists in POSIX shell: -
--#!/bin/sh -exit 0 --
-This happens to be nearly identical in source to the implementation used by NetBSD. -
--Python has the same 0 byte _code(`true(1)') implementation feature as most shells. -Here's _code(`false(1)') in Python rather than _code(`true(1)') to demonstrate how exiting with an arbitrary exit status can be done: -
--import sys -sys.exit(1) --
-In some shells, _code(`true(1)') is a shell built-in command, so running _code(`true') will run the shell author's implementation of _code(`true(1)') rather than the system implementation. -
--GNU _code(`true(1)'), from the GNU coreutils, is well known for being a maximalist implementation - it's eighty lines long and directly includes four C header files. -Their _code(`true.c') is 2.3 kilobytes and parses the arguments _code(`--help') and _code(`--version') (only if either are the first argument to the program). -The GNU coreutils implementation of _code(`true(1)') is not POSIX compliant. -
- --_code(`util-linux') is distributed on all popular Linux distributions and contains utilities users may expect to be already present on their systems, like _code(`more(1)') or _code(`hexdump(1)'). -
-