Commit Graph

74 Commits

Author SHA1 Message Date
wiz ac632886e5 Apply diff from Igor Sobrado <isd@orion.ciencias.uniovi.es>:
We have written a diff to our ls(1) to recover the traditional behaviour
of -f implying -a.  This change does not only accommodates POSIX.1
but also matches traditional UNIX.

OpenBSD commit message:

CVSROOT:        /cvs
Module name:    src
Changes by:     sobrado@cvs.openbsd.org 2014/03/31 14:54:37

Modified files:
        bin/ls         : ls.1 ls.c

Log message:
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-04-02 10:55:47 +00:00
mlelstv d85eb2bfe0 add u option to getopt again. 2014-02-22 13:08:13 +00:00
christos c7dda21c10 Add -X (don't cross mount points when recursing) from tls@ 2014-02-21 02:42:41 +00:00
christos 0c47a5c376 Add -O (only leaf files) and -P (print full path), from tls@ 2014-02-20 18:56:36 +00:00
abs 6f08f9dbdd PR/47167
ls.1:
- Sort options in `SYNOPSIS', the option list, and texts within
  the man page;
- improve wording;
- improve macro usage;
- use more consistency regarding (locations for) information about
  which options override which;
- cross-reference `-d' and `-R';
- simplify description of `-k', removing redundant and unneeded
  information;
- sort entry type list (but leave `-a' and `-A' as they are, given
  their meaning);
- correct / augment description of `BLOCKSIZE' environment variable
  in `ENVIRONMENT' section;
- bump date.

ls.c:
- Sort options in `usage';
- augment comment about when to figure out block size.
2012-11-20 12:37:29 +00:00
joerg 44db7ee6ac Move usage and mark it static+dead 2011-08-29 14:44:21 +00:00
erh 4aaf499c53 PR#7540, add a -M option to ls which causes sizes (and number of blocks) to be
displayed with comma separators (or a locale specific separator).
2011-03-15 03:52:37 +00:00
rmind 1126bbae2c Add #include <sys/param.h> for howmany(). 2010-07-08 20:43:34 +00:00
lukem 990d25a96c fix -Wsign-compare issues 2009-02-14 08:02:04 +00:00
lukem 41f5d0fda6 Change '-n' so that it implies '-l' rather than requires '-l'.
Brings ls(1) closer to POSIX.1 2004.
Per discussion with Thomas Klausner and Igor Sobrado.
2008-09-25 23:44:05 +00:00
lukem 2fe2731d3f Remove the \n and tabs from the __COPYRIGHT() strings. 2008-07-20 00:52:39 +00:00
he 0a97c3f688 Complete the move of string_to_flags() and flags_to_string() from the
bin/ls sources to libutil:
 o Bump libutil minor version number
 o Fix uses to include <util.h> to pick up the function definitions
 o Fix most uses of flags_to_string() to release the now-malloc()ed result
2006-12-14 20:09:35 +00:00
christos 78509e7f31 Pass lint. From Anon Ymous 2006-12-14 14:15:26 +00:00
elad 8fea60435c PR/34499: mac at S dot culver dot net: ls allocates more memory than needed
Applied patch, thanks!
2006-09-23 19:54:53 +00:00
christos eae5877e02 from zafer: you can have either -k or -h but not both since it does not make
sense.
2006-08-21 19:08:47 +00:00
christos 7e2f55514f Coverity CID 1755: Add fts_close() in traverse. 2006-03-22 16:20:34 +00:00
jschauma ea274fd69c Rather than '-h' suppressing '-s' when using '-l', make it display
the blocks used in human readable form, as suggested by Alan Barrett
and Daniel Carosone.
2005-10-26 02:24:22 +00:00
jschauma ff54312f75 Honor the COLUMNS variable even when producing output not to a terminal,
as long as a specific format (that could use COLUMNS) was requested.
This makes

env COLUMNS=50 ls -C > file

not surprise the user who clearly wanted some specific output in the file.
2005-10-14 16:02:26 +00:00
hira a2ed3bbe80 - Add -h to usage.
- Use set/getprogname(3).
2005-06-17 14:36:16 +00:00
simonb ba2dda9f8e Fix bug with previous change- always initialise d.s_block. Now "ls -1sh"
works.
XXX: ls -sh now always uses 4 chars for the size column width even if it
     needs less than that.
2003-12-26 10:51:25 +00:00
simonb c4d01568e0 KNF - wrap long lines. 2003-12-26 10:47:32 +00:00
grant f4c4780250 implement -h(umanize).
from David P. Reese Jr. in PR bin/23870.
2003-12-26 06:19:19 +00:00
jschauma 21ab633500 After last weeks addition of the '-b' flag, add '-B' and '-w' flags,
suggested by uwe@, inspired by FreeBSD.  The three flags override
each other (and the '-q' flag) and behave as follows:

     -B      Force printing of non-printable characters in file names as
	     \xxx, where xxx is the numeric value of the character in octal.

     -b      As -B, but use C escape codes whenever possible.

     -w      Force raw printing of non-printable characters.  This is the
             default when output is not to a terminal.
2003-09-22 02:43:19 +00:00
jschauma 2ccef82cc4 Implement '-b' option, which, following FreeBSD, Linux and (I think) Solaris
prints octal escapes for nongraphic characters.
2003-09-14 19:16:05 +00:00
agc b5b2954259 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22249, verified by myself.
2003-08-07 09:05:01 +00:00
simonb ae46649fa5 Pass a NULL to getbsize() for any arguments that aren't needed, and
remove the otherwise unused variables.
2003-05-30 00:17:25 +00:00
kleink 7c8d837e74 If both -g and -l options are present, let -l take precedence over -g,
as requested by several users.

POSIX-2001 is unclear on conflicting option letters as far as the -g
option is concerned; a clarification request will be made.

Addresses PR bin/21519 by Geoff Wing.
2003-05-11 08:06:01 +00:00
simonb 7efb28b165 Add a FALLTHROUGH to keep lint happy. 2003-05-07 13:23:32 +00:00
grant 75d0e9d0c0 make -g behave as it should according to SUSv3 (long listing without
owner).

ok'd by kleink@.
2003-05-07 13:00:24 +00:00
simonb 4bce9043f0 Need to initialise the blocksize variable if the -i option is used
too.  The code in display() could possibly be a bit smarter about this
requirement...

Fixes the problem in PR bin/18321 from David Laight and PR bin/18436
from FUKAUMI Naoki.
2002-09-27 12:01:51 +00:00
sommerfeld af723a4db0 Use the output blocksize when computing how much room to leave for the
-s option, to suppress unnecessary leading spaces.
2002-09-14 04:25:55 +00:00
lukem ba2e04dc88 convert to new KNF 2000-07-29 03:46:14 +00:00
assar c5a806697b Do not modify the file name when not printing non-printables, also do
it consistently with the file name and possible symbolic link target.

fixes bin/10385 and bin/10384
2000-06-17 16:11:25 +00:00
enami c3a9dd2e8d - Fix a typo that when group_from_gid is failed (though it merely fails
on NetBSD), numeric gid string is used as `user'.
- Don't mix use %u and %d for numeric uid/gid.
- Share temporary buffer.
2000-03-06 11:03:45 +00:00
drochner 85cbf55d16 Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
1999-11-09 15:06:30 +00:00
tron c87c6d5c86 Call setlocale(3) to use localization in "ls" as suggested by
Jens A Nilsson in PR bin/8730.
1999-11-02 19:44:07 +00:00
lukem 37085e7c0d Rename ls.c::main() -> ls.c::ls_main(), and add a wrapper in main.c::main().
This allows other programs to link in against ls (e.g, ftpd), without having
to have hacks to deal with multiple main()s.

Yes, I know this is ugly. The clean alternative (move lots of this
into libutil, yada yada yada) isn't fun, and the effort probably isn't
justified...
1999-05-17 12:16:03 +00:00
simonb a4b250cd02 If an error is encountered, exit with non-zero status.
Based on FreeBSD fix (in 1996!), and fixes PR bin/7514 from
Jorgen Pehrson.
1999-05-04 11:55:22 +00:00
kleink b424b8fe8c Add support for the XCU5 -p option (-F restricted to directories). 1999-02-17 15:28:08 +00:00
kleink b7443b0f16 Implement 1003.2 -m option (stream output format). 1999-02-12 14:35:48 +00:00
christos a7e8a30ca7 %q -> %ll 1998-11-04 18:53:17 +00:00
christos 7f10b1cf33 include termios.h for struct winsize 1998-11-04 18:50:22 +00:00
wsanchez 0a8ce08607 Check for NULL value returned by user_from_uid and group_from_gid and DTRT,
rather than crash.
1998-10-13 16:55:22 +00:00
thorpej 45e5a86960 Add some braces to make egcs happy. 1998-08-19 01:43:22 +00:00
mycroft 9dc385beb1 Delint. 1998-07-28 05:31:22 +00:00
mycroft 1381f68431 Delint. 1998-07-28 05:15:46 +00:00
mycroft ac70c0c5ed Slight code reduction. 1998-07-27 17:55:17 +00:00
mycroft 0e2f9ea923 __AUDIT__ cleanup. 1998-07-27 17:06:48 +00:00
lukem e30b76288b * blocks can be 64bit (not u_long), so calculate and display accordingly
* cleanup some other typedamage (int is as good as u_long)
* remove unused variables
1998-05-16 15:12:26 +00:00
mycroft 1ee799896c Deal with GCC warning. 1998-02-03 02:02:13 +00:00