aboutsummaryrefslogtreecommitdiff
path: root/bin/ls
Commit message (Collapse)AuthorAgeFilesLines
* ls.1: Mention CLICOLOR environment variableGordon Bergling2024-02-211-3/+5
| | | | | | | | | | Mention CLICOLOR environment variable in the manual page. PR: 276556 Submitted by: bsdcode at disroot dot org Reviewed by: imp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D43970
* ls: Fix -v and associated testWarner Losh2024-02-191-1/+2
| | | | | | | | 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
* ls: versort incompatible w/ timesort and sizesortAlexander Ziaee2024-02-022-7/+11
| | | | | | | ls.1: versort incompatible w/ timesort and sizesort Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/825
* Fix "version introduced" in numerous manual pagesTom Hukins2024-01-081-1/+1
| | | | | MFC after: 1 week Pull request: https://github.com/freebsd/freebsd-src/pull/853
* bin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-273-9/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-9/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* bin: Remove ancient SCCS tags.Warner Losh2023-11-278-19/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* Correct the grammo in "will underlined".Jens Schweikhardt2023-09-101-1/+1
|
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-166-6/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-164-9/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* ls: Improve POSIX compatibility for -g and -n.Minsoo Choo2023-07-185-21/+28
| | | | | | | | | | | | | | | | | | - Change -g (ignored for BSD 4.3 compatibility since BSD 4.4) to use POSIX semantics of implying -l but omitting the owner's name. - Change -n to imply -l. The -o option remains unchanged (POSIX defines -o as a complement to -g that implies -l but omits group names whereas BSD defines -o to add file flags to -l). This compromise is the same used by both NetBSD and OpenBSD. PR: 70813 Reviewed by: jhb, Pau Amma <pauamma@gundo.com> Co-authored-by: John Baldwin <jhb@FreeBSD.org> Differential Revision: https://reviews.freebsd.org/D34747
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-0/+1
|
* ls(1): add a -v flag to sort naturallyAymeric Wibo2022-10-306-12/+67
| | | | | | | | | | | | Add a -v flag for ls which sorts entries following a natural ordering using strverscmp(3) (e.g. "bloem1 bloem9 bloem10" as opposed to "bloem1 bloem10 bloem9"). Update the manual page and add a test case. Reviewed by: pauamma, bcr Tested by: pstef Differential Revision: https://reviews.freebsd.org/D36407
* Handle NULL return from localtime(3) in ls(1) and find(1)Kirk McKusick2022-09-091-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ls(1) (with -l option) and find(1) (with -ls option) utilties segment fault when operating on files with very large modification times. A recent disk corruption set a spurious bit in the mtime field of one of my files to 0x8000000630b0167 (576460753965089127) which is in year 18,266,940,962. I discovered the problem when running fsck_ffs(8) which uses ctime(3) to convert it to a readable format. Ctime cannot fit the year into its four character field, so returns ??? ??? ?? ??:??:?? ???? (typically Thu Nov 24 18:22:48 2021). With the filesystem mounted, I used `ls -l' to see how it would report the modification time and it segment faulted. The find(1) program also segment faulted (see script below). Both these utilities call the localtime(3) function to decode the modification time. Localtime(3) returns a pointer to a struct tm (which breaks things out into its component pieces: year, month, day, hour, minute, second). The ls(1) and find(1) utilities then print out the date based on the appropriate fields in the returned tm structure. Although not documented in the localtime(3) manual page, localtime(3) returns a NULL pointer if the passed in time translates to a year that will not fit in an "int" (which if "int" is 32-bits cannot hold the year 18,266,940,962). Since ls(1) and find(1) do not check for a NULL struct tm * return from localtime(3), they segment fault when they try to dereference it. When localtime(3) returns NULL, the attached patches produce a date string of "bad date val". This string is chosen because it has the same number of characters (12) and white spaces (2) as the usual date string, for example "Sep 3 22:06" or "May 15 2017". The most recent ANSI standard for localtime(3) does say that localtime(3) can return NULL (see https://pubs.opengroup.org/onlinepubs/9699919799/ and enter localtime in the search box). Our localtime(3) man page should be updated to indicate that NULL is a possible return. More importantly, there are over 100 uses of localtime(3) in the FreeBSD source tree (see Differential Revision D36474 for the list). Most do not check for a NULL return from localtime(3). Reported by: Peter Holm Reviewed by: kib, Chuck Silvers, Warner Losh MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36474
* For man page references found in ports, indicate the respective port.Jens Schweikhardt2022-08-141-2/+2
|
* ls(1): Allow LSCOLORS to specify an underlineCameron Katri2021-09-194-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
* ls: prevent no-color build from complaining when COLORTERM is non-emptyPiotr Pawel Stefaniak2021-08-191-5/+3
| | | | | | | | | | | | | | | As 257886 reports, if ls(1) is built with WITHOUT_LS_COLORS="YES", it issues a warning whenever COLORTERM is non-empty. The warning is not useful, so I thought to remove it, but as Ed pointed out, we may want to have a way to determine whether a particular copy of ls has been compiled with color support or not. Therefore move the warnx() call to the getopt loop in a WITHOUT_LS_COLORS build to fire when the user asks for colored output. PR: 257886 Reported by: Marko Turk Reviewed by: kevans
* Simplify LS_COLWIDTHS processingStefan Eßer2020-12-271-72/+43
| | | | | | | | | | | | | | The previous version normalized the width list (replaced empty fields with "0") just to be able to use sscanf() on the string. It is much simpler to just parse the string as-is. The clearing of f_notabs is preserved for the case that less than 9 width values have been defined, but I do not understand the rationale for this particular condition. E.g., LS_COLWIDTHS="::::::::" will be counted as 9 defined fields (may clear f_notabs) but is no different fron LS_COLWIDTHS="" with regard to the field width (and that does not clear f_notabs, since there are less than 9 fields).
* fts_read: Handle error from a NULL return better.Bryan Drewery2020-12-081-1/+1
| | | | | | | | | | | | | | | | | | | | This is addressing cases such as fts_read(3) encountering an [EIO] from fchdir(2) when FTS_NOCHDIR is not set. That would otherwise be seen as a successful traversal in some of these cases while silently discarding expected work. As noted in r264201, fts_read() does not set errno to 0 on a successful EOF so it needs to be set before calling it. Otherwise we might see a random error from one of the iterations. gzip is ignoring most errors and could be improved separately. Reviewed by: vangyzen Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D27184 Notes: svn path=/head/; revision=368467
* ls(1): Use \& as an escape character for the ',' optionGordon Bergling2020-10-101-1/+1
| | | | | | | | Reported by: karels@, xtouqh at hotmail dot com MFC after: 1 day Notes: svn path=/head/; revision=366613
* ls(1): Bugfix for an issue reported by mandocGordon Bergling2020-10-031-1/+1
| | | | | | | | | - no blank before trailing delimiter MFC after: 1 week Notes: svn path=/head/; revision=366403
* ls(1): Update all POSIX references and correct the STANDARDS sectionGordon Bergling2020-08-311-9/+10
| | | | | | | | | | | | | | | - Update the POSIX references for non-standard ls(1) options - Simplify the STANDARDS section by mention both supported POSIX versions Reported by: hrs Reviewed by: hrs, bcr Approved by: hrs, bcr MFC after: 3 days X-MFC-With: r364449 Differential Revision: https://reviews.freebsd.org/D26210 Notes: svn path=/head/; revision=365004
* ls(1): Update POSIX conformance from 2001 to 2008Gordon Bergling2020-08-211-10/+10
| | | | | | | | | | | | | | | | | | | - Update the options that are non-existing in POSIX from 2001 to 2008 - Update POSIX conformance in the STANDARDS section from 2001 to 2008 Verified by checking [1]. [1] https://pubs.opengroup.org/onlinepubs/9699919799.2016edition/toc.htm PR: 140435 Submitted by: Dan Lukes <dan at obluda dot cz> Reviewed by: bcr Approved by: bcr MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D26096 Notes: svn path=/head/; revision=364449
* ls: fix WITHOUT_LS_COLORS buildKyle Evans2020-05-211-0/+4
| | | | | | | | | | | *sigh* references to colorflags should be gated by COLORLS. Pointy hat to: kevans Reported by: jenkins (rescue build) X-MFC-With: r361318 Notes: svn path=/head/; revision=361332
* ls(1): actually restore proper behaviorKyle Evans2020-05-212-2/+16
| | | | | | | | | | | | | | | | | Highlights: - CLICOLOR in the environment should imply --color=auto to maintain compatibility with historical behavior - -G should set CLICOLOR and imply --color=auto The manpage has been updated to draw the connection between -G and --color; the former is in-fact a sort of compromise between --color=always and --color=auto, where we'll output color regardless of the environment lacking CLICOLOR/COLORTERM assuming stdout is a tty. X-MFC-With: r361318 Notes: svn path=/head/; revision=361331
* ls: fix a --color regression from r337956Kyle Evans2020-05-212-4/+10
| | | | | | | | | | | | | | | | | | The regression is in-fact that I flipped the default from never to auto. The incorrect impression was based on an alias that I failed to notice, installed by the Linux distribution that I used for testing compatibility here. Users that want the old default should be doing so with a shell alias as is done elsewhere, rather than making this decision in ls(1). Many thanks to rgrimes for pointing out the alias that I clearly overlooked that resulted in this; if you despised colors in your terminal from this, consider buying him a beer at the next venue that you see him at. MFC after: 1 week Relnotes: yes Notes: svn path=/head/; revision=361318
* ls(1): Fix trivial SEGV due to NULL deref in OOM pathConrad Meyer2020-05-051-0/+14
| | | | | | | | Reported by: Anton Rang <rang AT acm.org> Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=360665
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-2/+0
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* Add Makefile.depend.optionsSimon J. Gerraty2019-12-111-0/+8
| | | | | | | | | | | | | | | | | | | | Leaf directories that have dependencies impacted by options need a Makefile.depend.options file to avoid churn in Makefile.depend DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc can be set in local.dirdeps-options.mk which can add to those set in Makefile.depend.options See share/mk/dirdeps-options.mk Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22469 Notes: svn path=/head/; revision=355616
* Now that we have MK_LS_COLORS, we don't need RELEASE_CRUNCH check here.Warner Losh2019-07-151-2/+1
| | | | | | | | | The RELEASE_CRUNCH check is redundant here. We don't need it for releases anymore, and picobsd can control this more directly without making it a special case. Notes: svn path=/head/; revision=349990
* ls(1): Gate the do_color_* definitions behind COLORLSKyle Evans2018-08-181-0/+2
| | | | | | | Pointy hat to: me Notes: svn path=/head/; revision=338028
* ls(1): Support other aliases for --color arguments used by GNU ls(1)Kyle Evans2018-08-182-4/+48
| | | | | | | | | | | These aliases are supported and documented in the man page. For now, they will not be mentioned in the error when an invalid argument is encountered, instead keeping that list to the shorter 'preferred' names of each argument. Reported by: rgrimes Notes: svn path=/head/; revision=338027
* ls(1): Add --color=whenKyle Evans2018-08-175-13/+163
| | | | | | | | | | | | | | | | | | | --color may be set to one of: 'auto', 'always', and 'never'. 'auto' is the default behavior- output colors only if -G or COLORTERM are set, and only if stdout is a tty. 'always' is a new behavior- output colors always. termcap(5) will be consulted unless TERM is unset or not a recognized terminal, in which case ls(1) will fall back to explicitly outputting ANSI escape sequences. 'never' to turn off any environment variable and -G usage. Reviewed by: cem, 0mp (both modulo last-minute manpage changes Differential Revision: https://reviews.freebsd.org/D16741 Notes: svn path=/head/; revision=337956
* ls(1): Fix color env var checkingKyle Evans2018-08-161-2/+25
| | | | | | | | | | | | CLICOLOR will behavior as always- if present at all in the environment, allow colors. COLORTERM, recently enforced, will have to be both present and not empty. Submitted by: imp Notes: svn path=/head/; revision=337885
* ls(1): Enable colors with COLORTERM is set in the environmentKyle Evans2018-08-082-3/+13
| | | | | | | | | | | | | COLORTERM is the de facto standard, while CLICOLOR is generally specific to FreeBSD and ls(1). PR: 230101 Submitted by: D Green <dfrg@xsmail.com> (with manpage additions by myself) Reviewed by: cem ("LGTM" in PR; pre-manpage changes) MFC after: 1 week Notes: svn path=/head/; revision=337506
* Convert ls(1) to not use libxo(3)Conrad Meyer2018-01-178-235/+108
| | | | | | | | | | | | | | | | | | | | libxo imposes a large burden on system utilities. In the case of ls, that burden is difficult to justify -- any language that can interact with json output can use readdir(3) and stat(2). Logically, this reverts r291607, r285857, r285803, r285734, r285425, r284494, r284489, r284252, and r284198. Kyua tests continue to pass (libxo integration was entirely untested). Reported by: many Reviewed by: imp Discussed with: manu, bdrewery Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D13959 Notes: svn path=/head/; revision=328100
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-206-0/+12
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Add HAS_TESTS to all Makefiles that are currently using theEnji Cooper2017-08-021-0/+1
| | | | | | | | | `SUBDIR.${MK_TESTS}+= tests` idiom. This is a follow up to r321912. Notes: svn path=/projects/make-check-sandbox/; revision=321914
* Convert traditional ${MK_TESTS} conditional idiom for including testEnji Cooper2017-08-021-3/+1
| | | | | | | | | | | | | | directories to SUBDIR.${MK_TESTS} idiom This is being done to pave the way for future work (and homogenity) in ^/projects/make-check-sandbox . No functional change intended. MFC after: 1 weeks Notes: svn path=/head/; revision=321912
* Renumber copyright clause 4Warner Losh2017-02-287-7/+7
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Use uintmax_t to print st_nlink.Konstantin Belousov2017-02-161-4/+4
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=313798
* Fix ls_tests:o_flag with ZFS TMPDIRAlan Somers2016-12-151-1/+1
| | | | | | | | | | | | | | Unlike UFS or TMPFS, ZFS sets uarch automatically whenever a file is updated. The test must explicitly clear uarch to be portable across filesystems. Also, it doesn't need to run as root. PR: 215179 MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8741 Notes: svn path=/head/; revision=310118
* Skip ls tests that use sparse files if these are not supported.Julio Merino2016-08-241-0/+8
| | | | | | | | | | | | | | | | | Some of the ls(1) tests create really large sparse files to validate the number formatting features of ls(1). Unfortunately, those tests fail if the underlying test file system does not support sparse files, as is the case when /tmp is mounted on tmpfs. Before running these tests, check if the test file system supports sparse files by using getconf(1) and skip them if not. Note that the support for this query was just added to getconf(1) in r304694. Reviewed by: ngie Differential Revision: https://reviews.freebsd.org/D7609 Notes: svn path=/head/; revision=304741
* Use require.progs with bc instead of require.files with /usr/bin/bcEnji Cooper2016-05-291-1/+1
| | | | | | | | | | | This will make things more flexible if the program path changes in the future, and the test in and of itself doesn't call /usr/bin/bc -- it just calls bc MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=300939
* Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installedEnji Cooper2016-05-041-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | after r298107 Summary of changes: - Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that namespacing is kept with FILES appropriately, and that this shouldn't need to be repeated if the namespace changes -- only the definition of PACKAGE needs to be changed - Allow PACKAGE to be overridden by callers instead of forcing it to always be `tests`. In the event we get to the point where things can be split up enough in the base system, it would make more sense to group the tests with the blocks they're a part of, e.g. byacc with byacc-tests, etc - Remove PACKAGE definitions where possible, i.e. where FILES wasn't used previously. - Remove unnecessary TESTSPACKAGE definitions; this has been elided into bsd.tests.mk - Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES; ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk. - Fix installation of files under data/ subdirectories in lib/libc/tests/hash and lib/libc/tests/net/getaddrinfo - Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup) Document the proposed changes in share/examples/tests/tests/... via examples so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of replacing FILES. share/mk/bsd.README didn't seem like the appropriate method of communicating that info. MFC after: never probably X-MFC with: r298107 PR: 209114 Relnotes: yes Tested with: buildworld, installworld, checkworld; buildworld, packageworld Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=299094
* MFHGlen Barber2016-03-101-0/+11
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=296625
| * DIRDEPS_BUILD: Connect MK_TESTS.Bryan Drewery2016-03-091-0/+11
| | | | | | | | | | | | | | Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=296587