summaryrefslogtreecommitdiff
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* uuidgen: add -c for compact uuidBaptiste Daroussin2023-03-062-3/+35
| | | | | | | | | | | | | It generates the uuid string but without the hyphen Approved by: re (cperciva) MFC After: 3 days Reviews by: tcberner Differential Revision: https://reviews.freebsd.org/D38820 (cherry picked from commit b2b294f27cf4618d6f7510007b41882860a080b9) (cherry picked from commit 0ba66872bea87abdf13660d5a7946769fd7b118f) (cherry picked from commit 4cd30c640db978355cf2da666e2749189babda5e)
* nproc: denote an incompatiblity with LinuxMateusz Guzik2023-02-232-2/+7
| | | | | | | | | | | | | On Linux _NPROCESSORS_CONF reports CPU threads disabled by the kernel, while it does not on FreeBSD. Flip _NPROCESSORS_ONLN to _NPROCESSORS_CONF. While it keeps reporting the same value, it will automagically unbreak should someone change the above. Approved by: re (cperciva) (cherry picked from commit 059320b8c8de73a90514879cd1e2da397584cfde) (cherry picked from commit 117d4cafdcb806407e38266de44aebe0b4e62b6f)
* Add nproc(1)Mateusz Guzik2023-02-234-0/+191
| | | | | | | | | | | | | | | This program prints the number of CPU threads it can run on, while respecting cpusets (or not, depending on switches). It aims to be compatible with nproc as found in GNU coreutils. Approved by: re (cperciva) Reviewed by: des Reviewed by: pstef Differential Revision: https://reviews.freebsd.org/D38386 (cherry picked from commit 48bfd3597654490cdc43bf0f591a539d3a28b590) (cherry picked from commit 31f9db72a35bb20ad01d792eaaa1d6048252ab38)
* cp: Add tests involving sparse files.Dag-Erling Smørgrav2023-02-096-95/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D38290 (cherry picked from commit 822fa7ae1e3e7ed277e47e6de355387e524c6ee4) cp: Simplify the common case. * The allocated buffer is only used in the fallback case, so move it there. The argument for passing it in from the caller was that if malloc(3) were to fail, we'd want it to fail before we started copying anything, but firstly, it was already not in the right place to ensure that, and secondly, malloc(3) never fails (except in very contrived circumstances, such as an unreasonable RLIMIT_AS or RLIMIT_DATA). * Remove the mmap(2) option. It is almost never beneficial, especially when the alternative is copy_file_range(2), and it adds needless complexity and indentation. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: rmacklem, mav Differential Revision: https://reviews.freebsd.org/D38291 (cherry picked from commit 6c85042afcbbf4cd0fb7e7c03226c7249081e690) cp: Minor code cleanup. * Fix includes in utils.c, cf. style(9). * Fix type mismatch: readlink(2) returns ssize_t, not int. * It is not necessary to set errno to 0 as fts_read(3) already does it. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D38369 (cherry picked from commit cb96a0ef0040fa7968245ab203ab70a7ed2d275d) cp: Adjust the sparse file tests. * The sparsity check was ineffective: it compared the apparent size in bytes to the actual size in blocks. Instead, write a tool that reliably detects sparseness. * Some of the seq commands were missing an argument. * Based on empirical evidence, 1 MB holes are not necessarily large enough to be preserved by the underlying filesystem. Increase the hole size to 16 MB. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: cracauer Differential Revision: https://reviews.freebsd.org/D38414 (cherry picked from commit 8b418c83d175fde3b1f65210509ddcf2ac248d9f)
* df: Return non-zero status on write failure.Dag-Erling Smørgrav2023-02-091-8/+8
| | | | | | | | | | While here, complete the libxo conversion and switch return value to standard constants. MFC after: 1 week Sponsored by: Klara, Inc. Differential revision: https://reviews.freebsd.org/D38097 (cherry picked from commit c968598479917f52022b86d0089a9835ddcf2799)
* timeout: Move from /usr/bin to /binMateusz Piotrowski2023-02-078-0/+829
| | | | | | | | | | | | | | | | | | | | | | timeout(1) is used by /etc/rc.d/zfskeys. Unfortunately, having timeout(1) installed in /usr/bin causes problems when /usr is an encrypted ZFS partition. Implementing timeout(1) in sh(1) is not trivial. A more elegant solution is to move timeout(1) to /bin so that it is available to early services in the boot process. PR: 265221 Reviewed by: allanjude, des, imp Approved by: allanjude, des, imp Reported by: Ivan <r4@sovserv.ru> Fixes: 33ff39796ffe Add zfskeys rc.d script for auto-loading encryption keys Relnotes: yes Sponsored by: Modirum MDPay Sponsored by: Klara Inc. Differential Revision: https://reviews.freebsd.org/D38344 (cherry picked from commit e7ab133648a168c4bf7c11da840663c5581771d8)
* bin/uuidgen: add support for v4 uuidsTobias C. Berner2023-01-102-12/+67
| | | | | | | | | | | | | | | | The version 4 UUID is meant for generating UUIDs from truly-random or pseudo-random numbers. [1] bin/uuidgen gained the new flag '-r' to create version 4 UUID. [1] RFC 4122, https://www.rfc-editor.org/rfc/rfc4122#section-4.4 Reviewed by: pstef Approved by: bapt MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D37695 (cherry picked from commit f176fe8e7f638e585afcd2f4dd52a522c4648f63)
* ls(1): add a -v flag to sort naturallyAymeric Wibo2022-12-246-12/+67
| | | | | | Differential Revision: https://reviews.freebsd.org/D36407 (cherry picked from commit e2662256cdbc6ca9be49a66837f9725081cfa9d3)
* sh: Fix mismatch in array bounds for vforkexecshell().John Baldwin2022-11-111-1/+1
| | | | | | | | Reviewed by: imp, jilles, emaste Reported by: GCC -Warray-parameter Differential Revision: https://reviews.freebsd.org/D36760 (cherry picked from commit 10297a9ed488a9fff159ae495b61185e6f50e22a)
* pax: remove 4.4BSD compatibilityDag-Erling Smørgrav2022-11-0219-342/+112
| | | | | | | | | | | | | | | | | | | | | | | | | Sponsored by: Klara, Inc. (cherry picked from commit 30c30e220af30fbe8896a2bc4769b9ffd7fb43fb) pax: comment typo fixes from NetBSD / OpenBSD. Sponsored by: Klara, Inc. (cherry picked from commit 0266a5d610be4fb546475934125a037ca5748184) pax: name all supported formats. Sponsored by: Klara, Inc. (cherry picked from commit a8e8a914456878a67dfc5ef6f917a04be2e6a0c7) pax: update date parsing code (from OpenBSD) Sponsored by: Klara, Inc. MFC after: 1 week (cherry picked from commit d05e43bc0d5705919d057793aaa3e6d3df65f815)
* sh: read more profile files.Dag-Erling Smørgrav2022-11-021-0/+20
| | | | | | | | | | | | | | | | | | | | | | | Differential Revision: https://reviews.freebsd.org/D36505 MFC after: 1 month (cherry picked from commit 497cdf9673ec53d59634bb78862cd8dea3d5c155) sh: when loading profile, skip obvious scratch files. Differential Revision: https://reviews.freebsd.org/D36856 (cherry picked from commit d3890a547d201d1f5043e51baa406ac9d5d3a60a) sh: when loading profile, read only .sh files. Reviewers: jilles, eugen_grosbein.net, cy Subscribers: imp Differential Revision: https://reviews.freebsd.org/D37034 (cherry picked from commit 8d7221ca2dd5e0b6c633761b314cffed82ddca72)
* df: do not report a 100% full inode usage on fs without inodesBaptiste Daroussin2022-10-122-4/+10
| | | | | | | | | | | | | | | | | | Before: devfs 2 2 0 100% 0 0 100% /dev After: devfs 2 2 0 100% 0 0 - /dev The previous behaviour was confusing for end users and many monitoring tools Note the linux df tools is also using the same syntax '-' for such filesystem MFC After: 2 weeks Reviewed by: manu, emaste, imp Differential Revision: https://reviews.freebsd.org/D34515 (cherry picked from commit 2eee44bd5ebcb88bf304215be1b0c68b6802a924)
* sh(1): fix home/del key on mobaxterm envBaptiste Daroussin2022-10-121-0/+4
| | | | | | | | | | | | For $reason mobaxterm default on sending unusual sequence from home/del key, which makes libedit unabel to catch them and bind them correctly. mobaxterm seems popular on the windows environment, so add proper keybinding to default shrc configuration so it works out of box. Reported by: lme (cherry picked from commit f3aad18d5e57328469be0e3be9e17d7bc48e6822)
* sh(1): interactive mode improvementBaptiste Daroussin2022-10-121-0/+9
| | | | | | | | | | | In the default configuration add 2 bindings which has been requested by many during the HEADSUP discussion: * csh like arrow history navigation * ctrl-arrow to jump from word to words Add an alias to make the history command exist as an alias to fc -l. (cherry picked from commit ef0d94a3d34c880bd9f86cd842ee01b6075bc1d8)
* stty(1): provide details about interaction with job controlKonstantin Belousov2022-10-091-1/+27
| | | | | | PR: 266627 (cherry picked from commit a7eac018437e592a575f46a59151eedc7a742fa7)
* Handle NULL return from localtime(3) in ls(1) and find(1)Kirk McKusick2022-09-271-5/+6
| | | | (cherry picked from commit 927f8d8bbbed70f6c88d05c19b5b366f8e7532c9)
* date: attempt to more accurately describe year limitations with -vKyle Evans2022-09-181-2/+10
| | | | | | | | | | | | The previous description was both incorrect and incomplete in its description -- the 2038 limit doesn't apply on !i386 platforms, and it didn't note that values above 100 are accepted and interpreted differently. Further, it didn't note that absolute years are accepted. Reviewed by: pauamma_gundo.com (manpages) Sponsored by: Klara, Inc. (cherry picked from commit 9fcac31db4602518e1337b1455581ffcae9348a5)
* cp: Fix build without VM_AND_BUFFER_CACHE_SYNCHRONIZED.Alexander Motin2022-09-061-10/+9
| | | | | | | | | It allows to not use mmap() for small files, which is not helpful in case of ZFS. Should be no functional change. MFC after: 1 week (cherry picked from commit 35b7759c05cbc65c06d87141da79f0f80af0f458)
* sh: accept fc options grouped behind one '-'Piotr Pawel Stefaniak2022-08-246-21/+41
| | | | | | | | | | | | | | As per Utility Syntax Guidelines, accept both forms: -l -n and -ln. To do that, anticipate the source string for the next option that will be parsed by nextopt(). It's not always *argptr, sometimes it is nextopt_optptr. To simplify the check for not_fcnumber, slightly modify nextopt() to always nullify nextopt_optptr in cases where it would have been set to point to a NUL character. (cherry picked from commit 755a1be6d015287763b0f336d4e9b8179615f511)
* sh: nullify ENV in testsPiotr Pawel Stefaniak2022-08-243-3/+3
| | | | | | | This is to avoid loading .shrc which may contain commands that would result in output different than expected. (cherry picked from commit a1423456415ad4784b31513cfe11438d2446881f)
* sh: implement persistent history storageBaptiste Daroussin2022-04-305-2/+85
| | | | | | | | | | | | | | | | | | | | | Implement persistent history storage: the strategy is simple at start: loads the existing .sh_history file at exit dump it. The implementation respects the HISTFILE variable and its POSIX definition: ~/.sh_history is used if HISTFILE is not set. to avoid sh to create the history file, set HISTSIZE to 0 or HISTFILE to en empty value (cherry picked from commit 988b1bb0c54e50654112f0bd649aee68307a5a80) sh: try to avoid overwriting HISTFILE produced by other shells If an attempt to load history from an existing history file was unsuccessful, do not try to save command history to that file on exit. (cherry picked from commit 1f82fb3834105fd8f1186b1c6d719d8a24738180)
* cp: fix -R recursion detectionKyle Evans2022-04-242-42/+57
| | | | | | | | | | | | | | | | | | | | | | | The correct logic is a lot simpler than the previous iteration. We record the base fts_name to avoid having to worry about whether we needed the root symlink name or not (as applicable), then we can simply shift all of that logic to after path translation to make it less fragile. If we're copying to DNE, then we'll have swapped out the NULL root_stat pointer and then attempted to recurse on it. The previously nonexistent directory shouldn't exist at all in the new structure, so just back out from that tree entirely and move on. The tests have been amended to indicate our expectations better with subdirectory recursion. If we copy A to A/B, then we expect to copy everything from A/B/* into A/B/A/B, with exception to the A that we create in A/B. Reviewed by: bapt Sponsored by: Klara, Inc. (cherry picked from commit f00f8b4fbd268a212687984e44daa3e0d0a16b87)
* cp: fix some cases with infinite recursionKyle Evans2022-04-242-5/+147
| | | | | | | | | | | | | | | | | | | | | | | As noted in the PR, cp -R has some surprising behavior. Typically, when you `cp -R foo bar` where both foo and bar exist, foo is cleanly copied to foo/bar. When you `cp -R foo foo` (where foo clearly exists), cp(1) goes a little off the rails as it creates foo/foo, then discovers that and creates foo/foo/foo, so on and so forth, until it eventually fails. POSIX doesn't seem to disallow this behavior, but it isn't very useful. GNU cp(1) will detect the recursion and squash it, but emit a message in the process that it has done so. This change seemingly follows the GNU behavior, but it currently doesn't warn about the situation -- the author feels that the final product is about what one might expect from doing this and thus, doesn't need a warning. The author doesn't feel strongly about this. PR: 235438 Reviewed by: bapt Sponsored by: Klara, Inc. (cherry picked from commit 848263aad129c8f9de75b58a5ab9a010611b75ac)
* pax(1): Remove a few double words in source code commentsGordon Bergling2022-04-141-4/+4
| | | | | | - s/an an/an/ (cherry picked from commit ffedb32dd3683ebea41920f9fb61ba5404b50882)
* sh: fix autocompletion for commands that share name with a directoryPiotr Pawel Stefaniak2022-04-131-2/+33
| | | | (cherry picked from commit 68700941c7ad58d6fa8eda82f3f370d87670fa6a)
* ls(1): Allow LSCOLORS to specify an underlineCameron Katri2022-03-264-13/+30
| | | | | | | | | | Allows capitalizing the background color character to enable an underline instead of bold, capitalizing the foreground color char will still do bold. Differential Revision: https://reviews.freebsd.org/D30547 (cherry picked from commit 97c31821eb0b1180778ad2da660a1778c2cb4b62)
* ps: fix `ps -aa`Math Ieu2022-03-221-6/+1
| | | | | | | | Passing the -a flag multiple times made ps show no processes. Differential Revision: https://reviews.freebsd.org/D27215 (cherry picked from commit bf27a2253f6ba6ee3086046b837b2fe40e22c72c)
* cp: Make -P work without -R as per POSIXCameron Katri2022-03-093-9/+31
| | | | | | | | | | According to POSIX, cp should allow the `-P` flag to work whether `-R` is specified or not. Currently, the `-P` option only works along with `-R`. PR: 199466 (cherry picked from commit 97e13037915c22162f199461f56951793d669f57)
* cp: fix -R with linksKyle Evans2022-03-092-4/+83
| | | | | | | | The traversal was previously not properly honoring -H/-L/-P. Notably, we should not have been resolving symlinks encountered during traversal when either -H or -P are specified. (cherry picked from commit 33ad990ce974be50abdc25427b0f365699d83a34)
* bin/df: allow -t option to be used together with -lStefan Eßer2022-03-043-28/+103
| | | | | | | | | | | | | | | | The df command provides a -l option to exclude all non-local file systems and a -t option with a (positive or negative) list of file system types to display. This commit adds support for a combination of -l and -t. If both are specified, the parameter list of the -t option is applied on top of the selection of öocal file systems (independently of the order of the -l and -t options). E.g., "df -t noprocfs,sysfs -l" will select all local file systems except those of type procfs and sysfs. (cherry picked from commit f0fd4a32c4f7ab5eb008ab08a1a13cb20d4b30d2)
* echo(1): Replace errexit() with err(3)Hans Petter Selasky2022-01-071-20/+2
| | | | | | | | Differential revision: https://reviews.freebsd.org/D32501 Submitted by: christos@ Sponsored by: NVIDIA Networking (cherry picked from commit 4c537df51a16ce004b184010d306e550716f49ea)
* pkgbase: Put yellow pages programs to its own packageEmmanuel Vadot2022-01-051-1/+1
| | | | | | | | | | | YP is less and less used, split them to users have the choice to not install them. MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D33441 (cherry picked from commit 5abb10faa1ff471b45ac4f49ace2b79cc57d7c3c)
* src/bin/sh: Fix spelling errorsElyes HAOUAS2021-11-194-4/+4
| | | | | | Pull Request: https://github.com/freebsd/freebsd-src/pull/544 Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> (cherry picked from commit 48556dff3d028da85b864c6662534e1388a255c8)
* src/bin/mkdir: Spell occur correctly.Elyes HAOUAS2021-11-191-1/+1
| | | | | | Pull Request: https://github.com/freebsd/freebsd-src/pull/544 Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> (cherry picked from commit 28c3c137f64a7176d0ca877fb4f35ae17c7c5202)
* src/bin/pax: Fix spelling errorElyes HAOUAS2021-11-191-1/+1
| | | | | | | | "whats" -> "what's" Pull Request: https://github.com/freebsd/freebsd-src/pull/544 Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> (cherry picked from commit 8db446034e3e53969db8b211fb8635dd911d1133)
* src/bin/ps: Fix spelling errorElyes HAOUAS2021-11-191-1/+1
| | | | | | | | Spell interruptible correctly. Pull Request: https://github.com/freebsd/freebsd-src/pull/544 Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr> (cherry picked from commit 3fe686f25a0d0844dc3afd0b3b067ec46abdbc99)
* date: Capitalize seconds string in synopsesMateusz Piotrowski2021-11-072-4/+4
| | | | | | | | | | This makes it consistent with other date(1) implementations. Also, it feels more consistent since hours and minutes are already represented as HH and MM respectively. MFC after: 3 days (cherry picked from commit c537bf9d5903d0689321f83691341c93b5919172)
* date.1: Fix some style issues and examplesMateusz Piotrowski2021-11-071-22/+27
| | | | | | | | | | | | | | | | | - Use Cm instead of Ar or Sq for command modifiers of the -v flag. - Remove unnecessary "Ar ..." from the synopsis. It's not clear what it was referring to. - Add missing arguments to the -f and -v flags. - Stylize the dot before "ss" with Cm in the default format in the -f flag description. - Set LC_ALL=C in the last example so that the output format of date(1) always matches the specified format of the -f flag not matter the locale. - List the -f flag as optional in all usage lines in the synopsis. MFC after: 3 days (cherry picked from commit 00133d5c5e6aae01663eca40993abd5e6137425b)
* date: Clean up synopsesMateusz Piotrowski2021-11-072-17/+38
| | | | | | MFC after: 3 days (cherry picked from commit a12b16f48f747339ccae6dd80cc0c0c4ad5b7846)
* sh: Set PATH envvar after setting HOME in dotfileKa Ho Ng2021-10-311-2/+2
| | | | | | | | | | | | | In single-user mode, all env vars are absent, so exptilde() would not be able to expand ~ correctly. Place the lines setting PATH below HOME, so exptilde() would work as expected. Sponsored by: The FreeBSD Foundation Reviewed by: jilles, emaste Differential Revision: https://reviews.freebsd.org/D27003 (cherry picked from commit fcfa64801a4fe836ff481465ea068e791aa4ce6a)
* freebsd-version(1): Add -j flag to support jailsFaraz Vahedi2021-10-082-5/+37
| | | | | | | | | | | | Make freebsd-version(1) support jails by adding the -j flag which takes a jail jid or name as an argument. As with other options, -j flags stack and display in the order requested. Reviewed by: bcr (manpages), kevans MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25705 (cherry picked from commit f54b18fc4d72c566912b9a41601ed87a852960e7)
* hostname: avoid strcpy() overlap in -d flag handlingKyle Evans2021-10-031-3/+4
| | | | | | | | | We don't need the strcpy() anyways, just use a pointer to the hostname buffer and move it forward for `hostname -d`. Sponsored by: Klara, Inc. (cherry picked from commit 33c1e7271ac21a626829289780b88071ae46ec65)
* sh: improve command completionPiotr Pawel Stefaniak2021-09-251-4/+18
| | | | | | | | | | When there are many matches, find the longest common substring starting from the beginning of each command and use that to replace input. As an example: on my system, llv<tab> will be autocompleted to llvm- and another <tab> will print all matching llvm commands. (cherry picked from commit c866d0c798a20b8f0a92df524f4ddd0d81511c88)
* sh: reset sh bindings on bind -e, bind -vPiotr Pawel Stefaniak2021-09-251-0/+7
| | | | | | | | | | | Until this change, any bindings set in histedit() were lost on calls to bindcmd(). Only bind -e and bind -v call libedit's keymacro_reset(). Currently you cannot fool libedit/map.c:map_bind() by trying something like bind -le as when p[0] == '-', it does a switch statement on p[1]. (cherry picked from commit 9413dfd331e705a1d7909fe41f06a30e43c442f7)
* sh: improve command completionPiotr Pawel Stefaniak2021-09-251-21/+19
| | | | | | | | | | | | When multiple matches are found, we keep the provided string on the input line and print unique matches as suggestions. But the multiple matches might be the same command found in different directories, so we should deduplicate the matches first and then decide whether to autocomplete the command or not, based on the number of unique matches. (cherry picked from commit b8ff849cbddfee3404d6550cf98f53d6bb617707)
* ls: prevent no-color build from complaining when COLORTERM is non-emptyPiotr Pawel Stefaniak2021-08-281-5/+3
| | | | (cherry picked from commit ced2dcadccfcff8f7991b3cb5f6f70d6710eadfb)
* sh: fix NO_HISTORY buildPiotr Pawel Stefaniak2021-08-281-21/+21
| | | | (cherry picked from commit 35b253d9d238c46a710a0cd7ba027ec87ba7c8ba)
* kenv: allow listing of static kernel environmentsKyle Evans2021-08-262-9/+47
| | | | | | | | | The early environment is typically cleared, so these new options need the PRESERVE_EARLY_KENV kernel config(8) option. These environments are reported as missing by kenv(1) if the option is not present in the running kernel. (cherry picked from commit db0f26439357b78863e61985acd1e5acf75ce73d)
* kenv: s/dump/list/ to clarify meaningKyle Evans2021-08-261-3/+3
| | | | | | | The contents of the kenv will be dumped to stdout, while dump could have also meant 'discard'. Call it 'list' instead. (cherry picked from commit 46438b5366f9405beb6f76474a5aae822352f012)
* bin/ps: Avoid function name conflict with libc uname()Alex Richardson2021-08-053-3/+3
| | | | | | | | | | This prevents ps from being built with address sanitizer instrumentation. Reviewed By: trasz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31048 (cherry picked from commit 2423585b1de50dd2daea8478318e94ff80e0e6ec)