-l is required by LSB for login shell, all other shells: bash, zsh,
oksh, mksh, ... implements it.
with -l sh will act as a login shell and read the profile.
MFC After: 1 week
Obtained From: dash (3b7c8442bfe7c2fd0a6b0415df6ddf66a399fd55)
Reviewed by: kib, lme
Differential Revision: https://reviews.freebsd.org/D47681
(cherry picked from commit 65f5dd42f11cdcb7716e6cdd09fac2314c144c1f)
The intended value is:
-offset indent
If there's any typo such that the value doesn't match the pre-defined
strings, then the offset is the same width as the value. So by chance,
"-offset -ident" ended up being a standard-width indent (since the
default indent is 6 chars, and "-ident" also has 6 chars), whereas
"-offset -indent" had a longer indent, and "-offset ident" had a shorter
one.
Signed-off-by: Graham Percival <gperciva@tarsnap.com>
Reviewed by: mhorne, Alexander Ziaee <concussious.bugzilla@runbox.com>
MFC after: 3 days
Sponsored by: Tarsnap Backup Inc.
Pull Request: https://github.com/freebsd/freebsd-src/pull/1436
(cherry picked from commit c013ca2cf772194de340aeb452a6ccfe7e1cecd8)
Update the STANDARDS section for timeout(1) to
POSIX 1003.1-2024.
Update mandoc to be able to render the
new POSIX macro.
Reviewed by: bapt, bcr
Approved by: bapt
Obtained from: OpenBSD
Differential Revision: https://reviews.freebsd.org/D45691
(cherry picked from commit 044f94adff55f13130f03c0c170fa879c8febb5b)
* Don't use `asprintf()` when `strdup()` can do the job just as well.
* Fix a couple of typos in a comment.
Fixes: eeb04a736cb9
MFC after: 3 days
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D46533
(cherry picked from commit a8ddd1926a34fc20970d9ceaad71b31fc414b1c5)
date: Documentation nits.
* Fix spurious capitalization.
* Fix inconsistent quoting.
* Use `Dq` rather than ASCII double quotes.
MFC after: 3 days
Sponsored by: Klara, Inc.
Reviewed by: 0mp
Differential Revision: https://reviews.freebsd.org/D46622
(cherry picked from commit 355ebf80b1ed98cf7ca9c51ce7e3e6dcb376853d)
Make the system call honor `AT_SYMLINK_NOFOLLOW`.
Also enable this from `linux_faccessat2` where the issue arised the first time.
Update manual pages accordingly.
PR: 275295
Reported by: kenrap@kennethraplee.com
Approved by: kib@
Differential Revision: https://reviews.freebsd.org/D46267
(cherry picked from commit 5ab6ed93cd3680f8b69dd4d05823f4740a2bdef9)
Instead of initializing individual fields to zero, clear the entire
struct prior to populating it.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: 0mp, markj
Differential Revision: https://reviews.freebsd.org/D46097
(cherry picked from commit f890020d43bf2070f12ffec37bcd9579f6fb1347)
While here, remove a bogus comment about a gcc bug. The bug was in ls,
which used an incorrect format string, and in libc, which accepted it.
MFC after: 1 week
Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D46067
(cherry picked from commit 647d4a8cafd2c9b291cab388191bc7fcfe12a66b)
The tests related to nanosecond support were failing on amd64 due to
uninitialized timespec structure.
Fixes: eeb04a736cb9 date: Add support for nanoseconds
Reviewed by: markj
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D44975
(cherry picked from commit 7b390cb636899582243e4daa8edbdb30d686d9fb)
This patch introduces support for a conversion specification for
nanoseconds.
The format of %N is meant to be compatible with that of GNU date.
The nanoseconds conversion specification is implemented directly in
date(1) instead of libc (in strftime(3)) to avoid introducing
non-standard functions to libc at this time and modifying struct tm.
Apart from introducing the nanoseconds conversion specification, this
patch brings the following changes:
- The "ns" format for ISO 8061 dates is now unlocked. E.g., date -Ins
prints:
2024-04-22T12:20:28,763742224+02:00
- The -r flag when fed a file is now aware of the nanosecond part of the last
modification time.
- date(1) is now able to set the time with nanosecond precision. It is
not possible as of now to do that by specifying nanoseconds directly
via the command-line arguments. Instead, the -r flag can be used.
- date(1) is now using the clock_gettime(3) family of functions instead
of ctime(3) family of functions where possible.
Reviewed by: des, markj
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D44905
(cherry picked from commit eeb04a736cb9c07d191af886e25d5f198824658e)
People still believe that it is essential to run sync(8) a couple of
times before a reboot/halt. Document that this has not been necessary
for a long time now.
Reviewed by: imp, bcr, Pau Amma <pauamma@gundo.com>
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D33233
(cherry picked from commit 177ba183076bd6fe6b29b1d657b954cca256506b)
Some file flags prevent modification of file times, so they should be
set later. This matches NetBSD's behaviour.
Reviewed by: markj
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/1138
(cherry picked from commit 428f86fd2ff1fd2b073d556fac273c8c7f457376)
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D44805
(cherry picked from commit 64d6925d1901637125f9f739282e72c992657dc8)
cp: Additional sanity check.
Once we've successfully opened the file we've been asked to copy, check
that it's of the same type as FTS told us it was.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude, markj
Differential Revision: https://reviews.freebsd.org/D44806
(cherry picked from commit 9075d4cfad5b339aabdf8033623a2164898c2786)
cp: Use warnc().
MFC after: 1 week
Sponsored by: Klara, Inc.
(cherry picked from commit f070188c3ad6b87ee9ce220b21718333d1bd9d52)
Both wcount and wresid are ssize_t so this cast is not needed. Just
remove it so the code is easier to read.
Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Reviewed by: emaste, zlei
Pull Request: https://github.com/freebsd/freebsd-src/pull/1116
(cherry picked from commit 8b864151856fbba97fed16b1200248cf9f6f3ccf)
* Give link(1) its own usage message.
* Use getprogname(3) instead of rolling our own.
* Verify that the target file does not already exist.
* Add tests specific to link(1).
MFC after: 3 days
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D44635
(cherry picked from commit bee7cf9e97f6d7bdc918421a93270fa88659808b)
* When copying a directory, if the destination exists and is not a
directory, we would previously emit an error message and exit. The
correct behavior according to POSIX is to emit an error message and
continue without descending further into the source directory.
* When copying a directory, if the destination does not exist and we
fail to create it, we would previously emit an error message and
exit. The correct behavior according to POSIX is to emit an error
message and continue. Whether to descend further into the source
directory is explicitly left unspecified; GNU cp does not, which
seems to me to be the safer and less surprising option, so let's not
either.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D44577
(cherry picked from commit dd286b0dc187c351a9537a363840245d5505b15b)
cp: Correct the list of non-portable flags.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D44576
(cherry picked from commit aaa1806f68ef3102a9b888a03360f166b88618c8)
Capability rights passed to cap_rights_* are not simple bitmaks and
cannot be ORed together in general (although it will work for certain
subsets of rights).
PR: 277057
Reported by: asomers, markj
(cherry picked from commit 05f530f4d2bb15fda3d258b3bd92d4515d9ef39f)
The cleanup of d854370fa86b7 had a cut and paste error (so f_verssort
was set to 1 and then to 0 rather thame f_timesort being set to 0).
Fixes: d854370fa86b7
Sponsored by: Netflix
(cherry picked from commit ef75877fc2d93199aab2b509089136c433af1f20)
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43052
(cherry picked from commit 1fead66b64822f3f8106ad09bef0b9656836fa1a)
cp: Add tests for symbolic link case.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D43054
(cherry picked from commit d3a8e9b43b4cef5b80e3845dfa8fd1fec6e568f9)
cp: Refactor the core logic.
Rewrite `copy_file()` so the lflag and sflag are handled as early as
possible instead of constantly checking that they're not set and then
handling them at the end. This also opens the door to changing the
failure logic at some future point (for instance, we might decide to
fall back to copying if `errno` indicates that the file system does not
support links).
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D43055
(cherry picked from commit d002316fd7bf0b359ea2f5518f3c10f6ad89a9ac)
cp: Split the basic_symlink test case in two.
This test case tests two different things: first, that copying a symlink
results in a file with the same contents as the target of the symlink,
rather than a second symlink, and second, that cp will refuse to copy a
file to itself, or to a link to itself, or a link to its target. Leave
the first part in basic_symlink, move the second part to a new test case
named samefile, and slightly expand both cases.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43062
(cherry picked from commit ac56b9d83c75f548667912ffe422be6bd4f5c27e)
cp: Move the flags around a bit.
- The HLPR flags are grouped together at the beginning because they are
the standard flags for programs using FTS. Move the N flag out from
among them to its correct place in the sequence.
- The Pflag variable isn't used outside main(), but moving it out lets
us skip initialization and keeps it with its friends H, L and R.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43063
(cherry picked from commit 0f4467ce444b201468d2268958130f495951ca3c)
cp: Further simplify the core logic.
If the destination file exists but we decide unlink it, set the dne
flag. This means we don't need to re-check the conditions that would
have caused us to delete the file when we later need to decide whether
to create or replace it.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43064
(cherry picked from commit 38509270663f336103273878cc8ddc88a225b9d8)
cp: Move the -N flag in the manual page.
This accidentally got left out of 0f4467ce444b.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D43067
(cherry picked from commit 53fc8e190241233d94e183f8a39ec39f2154dfa8)
Add -N to supress copying of file flags when -p is specified (explicitly
or implicitly). Often times we don't care about the flags or wish to be
able to copy to NFS, and this comes in handy for that. FreeBSD's and
NetBSD's cp are somewhat different, so I had to reimplement all but one
of the patch hunks...
Obtained from: NetBSD (cp.1 1.25, cp.c 1.37, utils.c 1.28 by elad)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42673
(cherry picked from commit 5a52e3d00dd5e0209f6fcb1e41b5985191e6f4e7)
cp: Don't warn for chflags() failing with EOPNOTSUPP if flags == 0
From NetBSD's utils.c 1.5 importing importing BSDI change, with light
formatting changes:
Author: cgd <cgd@NetBSD.org>
Date: Wed Feb 26 14:40:51 1997 +0000
Patch from BSDI (via Keith Bostic):
>NFS doesn't support chflags; ignore errors unless there's reason
>to believe we're losing bits. (Note, this still won't be right
>if the server supports flags and we were trying to *remove* flags
>on a file that we copied, i.e., that we didn't create.)
CVS Info: utils.c 1.6
Obtained from: NetBSD
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42674
(cherry picked from commit 3e7e3b5bdf902a375decc11b95179fd2fbc0da2a)
This uses more generic wording in the FreeBSD installer, when offering
the user to use the system booted without running the installer.
The updated wording is also reflected in freebsd-version(1).
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D43233
(cherry picked from commit 19bb1886be4f366e922f0be359874683a243624a)
According to /etc/mtree/BSD.root.dist /root should have
0750 permissions, but the build target 'make installworld'
changes these to 0755.
This is caused by the installation of the configuration
files of sh(1) and csh(1).
Correct this by specifying the correct default /root permissions.
PR: 273342
Reviewed by: jilles
Approved by: jilles
MFC after: 2 weeks
Differential Revision:https://reviews.freebsd.org/D42395
(cherry picked from commit a6ed8c9593031abf6fa73661be55c226caa362d6)
The filesystem may support reading directories directly
when security.bsd.allow_read_dir is set.
PR: 275099
(cherry picked from commit 3c773cad57064c23873f286fbec69f6f0305b889)
This patch adds the necessary kernel and stty code to support setting
the IUTF8 flag for ttys. It is the first of two patches that fix
backspace behaviour for UTF-8 encoded characters when in canonical mode.
Reported by: christos
Reviewed by: christos, imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D42066
(cherry picked from commit 128f63cedc14ae21b35f74e11e2fe1a5659c58e8)
This is useful to have a valid /etc/hostid and /etc/machine-id for
small mfsroot based setup and not needing to install FreeBSD-utilities
Sponsored by: Beckhoff Automation GmbH & Co. KG
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D42149
(cherry picked from commit 6a804af4c0e3ce3574e23695f587c11f5958bcbb)
It takes a non-optional parameter string, one of "up", "down", or "both"
that can request tree traversal in the chosen directions. This adds PIDs
from the paths to the selection of PIDs and can be used together with -d
to draw a subset of the process tree.
Differential Revision: https://reviews.freebsd.org/D41231
This reverts commit ca8c0d5e81.
By commiting ca8c0d5e81 I was hoping that the existing option -d
could just be extended to work with -p to implement a feature that was
and I think is still needed, that is to show all descendant processes
of a given process id or a set of process ids.
After a complaint from -current which may represent a wider
dissatisfaction with this change in the program's behavior, I think it
will be better to revert ca8c0d5e81 and reintroduce this feature
using a separate option -D.
The change made in e835ee68e1 did not
follow the convention for relative path symlinks. Per the convention,
paths be prefixed with `${BINDIR}`, not `/bin/`. `${BINDIR}` can be
modified from the Makefile, on the command line, or in the
environment. This convention is the canonically correct way to do
things.
This follows the convention used in `bin/pkill/Makefile`,
`bin/timeout/Makefile`, etc.
MFC after: 1 week
MFC with: f05948d4e9
MFC with: e835ee68e1
Requested by: jrtc27, kevans