1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-02 22:35:36 -08:00
Commit Graph

158 Commits

Author SHA1 Message Date
millert
ba906cc60a printtime: use the Unix epoch if the file's timestamp is invalid
Fixes a crash in "ls -l" for files with bogus timestamp values.
OK miod@ denis@
2024-03-27 14:44:52 +00:00
schwarze
772e31c152 Simplify the display() function by getting rid of a useless buffer
on the stack.  No functional change, +8 -15 LOC.

Suggested by and OK millert@.
2023-10-07 13:29:08 +00:00
schwarze
09b34e9cf9 Improve horizontal alignment in long format when printing minor
device numbers greater than 999 by measuring the two widths needed
for device numbers just like it is already done for other numbers.
In the output, this only changes whitespace, but not the text.

Ugly formatting reported by
Crystal Kolipe <kolipe dot c at exoticsilicon dot com>.

OK millert.  Also tested by Crystal Kolipe.
2023-10-07 11:51:08 +00:00
guenther
6fa343ac6c Replace use of the old BSD st_*timensec members in struct stat with
the POSIX-standard st_*tim.tv_nsec members.

ok millert@
2023-08-08 04:45:44 +00:00
millert
bc2593c5af If we are asked to print the total number of blocks, do so even if
we have no entries to print (either due to an empty directory or
an error).  This makes the -l and -s options more consistent, and
matches the behavior of AT&T and GNU ls.  From FreeBSD (das).
OK kn@
2020-10-07 21:03:09 +00:00
millert
b3b446690c Always print the directory name in -R mode; matches historical behavior.
Previously, our ls would only print the directory name when listing
more than one directory, which is the correct behavior for non-recursive
ls but not for -R mode.  OK deraadt@
2020-07-06 00:55:05 +00:00
millert
b352e5558a Fix skipping of directories that begin with a '.' in -R mode.
It is not enough to avoid displaying the contents of the directory,
we need to set FTS_SKIP to avoid descending into any subdirs too.
Otherwise, if a ".foo" directory has a subdirectory "bar", ls will
descend into bar and display its contents.  OK deraadt@
2020-07-06 00:51:51 +00:00
deraadt
7aa9f692dc dev_t is signed to permit passing -1 as an invalid condition, but the
decomposition into major and minor is unsigned, so we should print them
with %u instead of %d.
ok guenther
2019-02-05 02:17:32 +00:00
millert
cdc5a29bb5 Fix warnings caused by user_from_uid() and group_from_gid() now
returning const char *.
2018-09-13 15:23:32 +00:00
deraadt
c4db6faa7f use sizeof, rather than the constant. on change in binary. 2018-02-04 22:09:33 +00:00
deraadt
55333ed9ed repair ugly indents 2018-02-04 21:53:54 +00:00
schwarze
4da37b8eba Unify wording for LC_CTYPE in ENVIRONMENT:
* Consistently use "character encoding locale" as suggested by stsp@.
* Resolve various gratuitious wording variations.
OK jmc@.
2016-10-24 13:46:58 +00:00
jmc
b4f1a09cff it seems we hyphenate it set-group-id;
from daniel bolgheroni
2016-09-08 05:52:19 +00:00
krw
9b082f83dc Nuke some erroneous leading whitespace. 2016-08-16 16:13:32 +00:00
krw
4442fdb76b Bring types of variables used with struct stat into the modern world.
Replace a couple of u_long paramaters with int as they were only passed int
values and the function re-cast them to (int) anyway. Weird.

ok tedu@
2016-08-16 16:09:24 +00:00
krw
7e8a4e4e69 %*qd -> %*lld + (long long) for off_t.
Avoid some casts by changing printsize() to take an int (the only
type actually passed via that parameter) instead of size_t.

Tweaks & ok guenther@
2016-08-15 16:57:53 +00:00
schwarze
3a0c2a3aec fix HISTORY; from Sevan Janiyan <venture37 at geeklan dot co dot uk>;
checked with http://minnie.tuhs.org/cgi-bin/utree.pl?file=V1/man/man1
2016-08-10 19:46:43 +00:00
chl
cf28062479 remove unused variable
ok schwarze@
2016-03-28 11:25:35 +00:00
jmc
bd58ad097a simplify previous; ok bentley 2016-03-17 07:18:33 +00:00
bentley
7220d8ecee Switch (non-curses, non-ksh) programs that use COLUMNS to a single idiom.
Previously behaviors were all over the map. This changes them to
use COLUMNS first, and either terminal width or a hardcoded value
(typically 80) as appropriate.

ok deraadt@; man bits ok jmc@
2016-03-17 05:27:10 +00:00
bentley
23ebb1e26d Mark up COLUMNS as an environment variable.
ok jmc@ schwarze@
2016-03-11 02:35:57 +00:00
schwarze
f96b7276b0 Fix a regression (and POSIX violation) introduced with UTF-8 support:
When neither running on a terminal nor with -q, names must be passed
through as they are, nothing must be replaced with question marks.
Effectively, -q was always in effect.  SMALL was not affected.

Triggered by a different patch from Martijn van Duren <openbsd plus tech
at list dot imperialat dot at>, who confirmed that this version is better.
Identified as a regression by tedu@.
OK sthen@.
2016-01-18 19:06:37 +00:00
schwarze
b6203726b0 Support UTF-8: use wcwidth(3) for column adjustment and replace
non-printable Unicode codepoints and invalid bytes with ASCII
question marks.  No change for the SMALL version.

Using ideas developed by tedu@, phessler@, bentley@ and feedback from many.
OK yasuoka@ czarkoff@ sthen@.
2015-12-01 18:36:13 +00:00
deraadt
0bd1216cbf Change all tame callers to namechange to pledge(2). 2015-10-09 01:37:06 +00:00
deraadt
9978c3c0a0 ls can use tame "stdio rpath getpw". It does uid/gid lookups, using
the 4.4bsd libc caching varients called user_from_uid/group_from_uid,
which are backed by getpw*/getgr* type functions.
ok semarie
2015-10-04 16:00:43 +00:00
uebayasi
f12e5d267f Put fts_close() where missing.
Not bugs in short-lived commands that call exit() -> _exit() immediately,
but for idempotency.

Originally found in ls(1) by Valgrind.  Changes for other commands are
from deraadt@.  Reviewed by me, tested in snapshots.

OK deraadt@
2015-06-25 02:04:07 +00:00
sobrado
49e12f67e4 improve wording.
ok jmc@
2015-04-24 10:57:36 +00:00
deraadt
a47b6461a1 Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert
2015-04-18 18:28:36 +00:00
millert
f7055df57d tzfile.h is an internal header that should never have been installed.
What's worse, the tzfile.h that gets installed is over 20 years old
and doesn't match the real tzfile.h in libc/time.  This makes the
tree safe for /usr/include/tzfile.h removal.  The TM_YEAR_BASE
define has been moved to time.h temporarily until its usage is
replaced by 1900 in the tree.  Actual removal of tzfile.h is pending
a ports build.  Based on a diff from deraadt@
2015-03-15 00:41:27 +00:00
deraadt
b9fc9a728f Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)
2015-01-16 06:39:28 +00:00
tedu
c0bbadaa95 reallocarray 2014-05-06 20:55:10 +00:00
jmc
7f5741cefc slightly reword -f; ok sobrado schwarze 2014-04-01 16:43:16 +00:00
sobrado
cad8a15cb1 restore the traditional behavior of -f implying -a; apparently Keith Bostic
forgot to restore it when the -f flag was put back on 2nd of September 1989,
after being removed on 16th of August as a consequence of issues getting it
working over NFS, so deviation from traditional UNIX behavior in all BSDs
looks like an historical accident; as a side effect, this change accommodates
behavior of this option to IEEE Std 1003.1-2008 (``POSIX.1'').

joint work with jmc@ (who found the inaccuracy in our implementation),
schwarze@ (who provided a detailed tracking of historical facts) and millert@

ok millert@, schwarze@
2014-03-31 20:54:37 +00:00
jmc
a0eee1efa3 revert previous: i was wrong;
thanks thomas klausner for noticing
2014-03-31 07:06:20 +00:00
jmc
38f6e38cd4 a pesky comma rendered the text describing how output is sorted relevant
only to the "if more than one operand is given" scenario; replace it
with a full stop and start a new paragraph;

ok millert
2014-03-30 07:26:12 +00:00
jmc
e8de5af14c expand STANDARDS somewhat; ok millert 2014-03-28 18:33:26 +00:00
guenther
64a7b209fc Per POSIX, times in the future should be reported with the year
like files more than six months old.  Use strftime() directly instead
of breaking down the ctime() output on character positions.

ok millert@
2014-01-09 03:07:52 +00:00
deraadt
cd3e3e8c82 add unsigned char casts for specific calls to ctype.h macros.
ok guenther step
2013-11-21 15:54:44 +00:00
guenther
3e12fe88c8 Fix column padding of inode numbers and block counts >2^32, as well as
display of directory block totals >2^32

ok tedu@
2013-05-30 16:34:32 +00:00
deraadt
6be702bba0 handle large ino_t; ok millert 2013-04-23 18:08:40 +00:00
deraadt
75f929694c remove some unnecessary sys/cdefs.h inclusions 2012-12-04 02:26:59 +00:00
guenther
bb325d81bc With the -l option, only call time() once per run instead of once per file
ok deraadt@
2012-07-12 09:41:09 +00:00
jmc
dc2cf4e428 use the same format/text, as far as possible, for date strings;
help/ok guenther millert
2011-08-31 08:48:40 +00:00
jmc
9f9ed71fc5 fix description of -g; from Pascal Stumpf 2011-03-05 15:57:03 +00:00
jmc
923c3fdea0 tweak; ok okan 2011-03-05 15:46:02 +00:00
okan
9079317df9 add support for the (POSIX) -H flag
feedback and ok millert@, sobrado@, jmc@
2011-03-04 21:03:19 +00:00
sobrado
8e74991cd6 remove trailing spaces and tabs from source code; no binary change. 2010-09-12 20:16:29 +00:00
jmc
59a5f2b984 add an EXIT STATUS section for /bin; 2010-09-03 09:53:20 +00:00
deraadt
043fbe51c1 rcsid[] and sccsid[] and copyright[] are essentially unmaintained (and
unmaintainable).  these days, people use source.  these id's do not provide
any benefit, and do hurt the small install media
(the 33,000 line diff is essentially mechanical)
ok with the idea millert, ok dms
2009-10-27 23:59:19 +00:00
jmc
609f1f5e03 - more opaque removal
- sort the flags list while here

ok martynas tedu
2009-08-21 07:11:01 +00:00