Sync with FreeBSD: When doing "ls -G /path/to/symlink", use the symlink

color instead of the color of the link target.
This commit is contained in:
naddy 2015-06-18 20:43:01 +00:00
parent c83de41e15
commit 890c1e2ba3
2 changed files with 22 additions and 6 deletions

View File

@ -1,10 +1,11 @@
# $OpenBSD: Makefile,v 1.30 2015/03/16 14:17:48 naddy Exp $
# $OpenBSD: Makefile,v 1.31 2015/06/18 20:43:01 naddy Exp $
COMMENT= ls that can use color to display file attributes
COMMENT= ls(1) that can use color to display file attributes
VERSION= 5.7
DISTNAME= ls-${VERSION}
PKGNAME= colorls-${VERSION}
REVISION= 0
CATEGORIES= sysutils
MAINTAINER= Christian Weisgerber <naddy@openbsd.org>

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-ls_c,v 1.13 2011/11/12 12:31:21 naddy Exp $
--- ls.c.orig Fri Mar 4 22:03:19 2011
+++ ls.c Sat Nov 12 13:17:42 2011
$OpenBSD: patch-ls_c,v 1.14 2015/06/18 20:43:01 naddy Exp $
--- ls.c.orig Mon Mar 31 22:54:37 2014
+++ ls.c Thu Jun 18 22:35:05 2015
@@ -42,12 +42,17 @@
#include <errno.h>
#include <fts.h>
@ -69,7 +69,7 @@ $OpenBSD: patch-ls_c,v 1.13 2011/11/12 12:31:21 naddy Exp $
case 'H':
fts_options |= FTS_COMFOLLOW;
break;
@@ -248,11 +272,46 @@ ls_main(int argc, char *argv[])
@@ -248,19 +272,59 @@ ls_main(int argc, char *argv[])
if (f_grouponly == -1)
f_grouponly = 0;
@ -117,3 +117,18 @@ $OpenBSD: patch-ls_c,v 1.13 2011/11/12 12:31:21 naddy Exp $
sortkey == BY_NAME)
fts_options |= FTS_NOSTAT;
/*
* If not -F, -d or -l options, follow any symbolic links listed on
- * the command line.
+ * the command line, unless in color mode in which case we need to
+ * distinguish file type for a symbolic link itself and its target.
*/
- if (!f_longform && !f_listdir && !f_type)
+ if (!f_longform && !f_listdir && !f_type
+#ifdef COLORLS
+ && !f_color
+#endif
+ )
fts_options |= FTS_COMFOLLOW;
/* If -l or -s, figure out block size. */