ls.c (57003) | ls.c (61178) |
---|---|
1/* 2 * Copyright (c) 1989, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Michael Fischbein. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 31 unchanged lines hidden (view full) --- 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /* not lint */ 42 43#ifndef lint 44#if 0 45static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94"; 46#else 47static const char rcsid[] = | 1/* 2 * Copyright (c) 1989, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Michael Fischbein. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 31 unchanged lines hidden (view full) --- 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /* not lint */ 42 43#ifndef lint 44#if 0 45static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94"; 46#else 47static const char rcsid[] = |
48 "$FreeBSD: head/bin/ls/ls.c 57003 2000-02-05 18:42:36Z joe $"; | 48 "$FreeBSD: head/bin/ls/ls.c 61178 2000-06-02 14:53:42Z joe $"; |
49#endif 50#endif /* not lint */ 51 52#include <sys/types.h> 53#include <sys/stat.h> 54#include <sys/ioctl.h> 55 56#include <dirent.h> --- 49 unchanged lines hidden (view full) --- 106int f_reversesort; /* reverse whatever sort is used */ 107int f_sectime; /* print the real time for all files */ 108int f_singlecol; /* use single column output */ 109int f_size; /* list size in short listing */ 110int f_statustime; /* use time of last mode change */ 111int f_timesort; /* sort by time vice name */ 112int f_type; /* add type character for non-regular files */ 113int f_whiteout; /* show whiteout entries */ | 49#endif 50#endif /* not lint */ 51 52#include <sys/types.h> 53#include <sys/stat.h> 54#include <sys/ioctl.h> 55 56#include <dirent.h> --- 49 unchanged lines hidden (view full) --- 106int f_reversesort; /* reverse whatever sort is used */ 107int f_sectime; /* print the real time for all files */ 108int f_singlecol; /* use single column output */ 109int f_size; /* list size in short listing */ 110int f_statustime; /* use time of last mode change */ 111int f_timesort; /* sort by time vice name */ 112int f_type; /* add type character for non-regular files */ 113int f_whiteout; /* show whiteout entries */ |
114int f_color; /* add type in color for non-regular files */ |
|
114 115int rval; 116 117int 118main(argc, argv) 119 int argc; 120 char *argv[]; 121{ --- 21 unchanged lines hidden (view full) --- 143 termwidth = atoi(p); 144 } 145 146 /* Root is -A automatically. */ 147 if (!getuid()) 148 f_listdot = 1; 149 150 fts_options = FTS_PHYSICAL; | 115 116int rval; 117 118int 119main(argc, argv) 120 int argc; 121 char *argv[]; 122{ --- 21 unchanged lines hidden (view full) --- 144 termwidth = atoi(p); 145 } 146 147 /* Root is -A automatically. */ 148 if (!getuid()) 149 f_listdot = 1; 150 151 fts_options = FTS_PHYSICAL; |
151 while ((ch = getopt(argc, argv, "1ABCFHLPRTWabcdfgiklnoqrstu")) != -1) { | 152 while ((ch = getopt(argc, argv, "1ABCFGHLPRTWabcdfgiklnoqrstu")) != -1) { |
152 switch (ch) { 153 /* 154 * The -1, -C and -l options all override each other so shell 155 * aliasing works right. 156 */ 157 case '1': 158 f_singlecol = 1; 159 f_column = f_longform = 0; --- 21 unchanged lines hidden (view full) --- 181 f_statustime = 0; 182 break; 183 case 'F': 184 f_type = 1; 185 break; 186 case 'H': 187 fts_options |= FTS_COMFOLLOW; 188 break; | 153 switch (ch) { 154 /* 155 * The -1, -C and -l options all override each other so shell 156 * aliasing works right. 157 */ 158 case '1': 159 f_singlecol = 1; 160 f_column = f_longform = 0; --- 21 unchanged lines hidden (view full) --- 182 f_statustime = 0; 183 break; 184 case 'F': 185 f_type = 1; 186 break; 187 case 'H': 188 fts_options |= FTS_COMFOLLOW; 189 break; |
190 case 'G': 191 if (isatty(STDOUT_FILENO)) 192 f_color = 1; 193 break; |
|
189 case 'L': 190 fts_options &= ~FTS_PHYSICAL; 191 fts_options |= FTS_LOGICAL; 192 break; 193 case 'P': 194 fts_options &= ~FTS_COMFOLLOW; 195 fts_options &= ~FTS_LOGICAL; 196 fts_options |= FTS_PHYSICAL; --- 57 unchanged lines hidden (view full) --- 254 default: 255 case '?': 256 usage(); 257 } 258 } 259 argc -= optind; 260 argv += optind; 261 | 194 case 'L': 195 fts_options &= ~FTS_PHYSICAL; 196 fts_options |= FTS_LOGICAL; 197 break; 198 case 'P': 199 fts_options &= ~FTS_COMFOLLOW; 200 fts_options &= ~FTS_LOGICAL; 201 fts_options |= FTS_PHYSICAL; --- 57 unchanged lines hidden (view full) --- 259 default: 260 case '?': 261 usage(); 262 } 263 } 264 argc -= optind; 265 argv += optind; 266 |
267 if (f_color) 268 parsecolors(getenv("LSCOLORS")); 269 |
|
262 /* 263 * If not -F, -i, -l, -s or -t options, don't require stat | 270 /* 271 * If not -F, -i, -l, -s or -t options, don't require stat |
264 * information. | 272 * information, unless in color mode in which case we do 273 * need this to determine which colors to display. |
265 */ | 274 */ |
266 if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type) | 275 if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type 276 && !f_color) |
267 fts_options |= FTS_NOSTAT; 268 269 /* 270 * If not -F, -d or -l options, follow any symbolic links listed on 271 * the command line. 272 */ 273 if (!f_longform && !f_listdir && !f_type) 274 fts_options |= FTS_COMFOLLOW; --- 383 unchanged lines hidden --- | 277 fts_options |= FTS_NOSTAT; 278 279 /* 280 * If not -F, -d or -l options, follow any symbolic links listed on 281 * the command line. 282 */ 283 if (!f_longform && !f_listdir && !f_type) 284 fts_options |= FTS_COMFOLLOW; --- 383 unchanged lines hidden --- |