bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stat(1) [was: Another testsuite nit: `set -']


From: Eric Blake
Subject: stat(1) [was: Another testsuite nit: `set -']
Date: Mon, 02 May 2005 07:04:04 -0600
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Paul Eggert on 4/29/2005 3:51 PM:
>       * tests/mkdir/perm: Don't use 'set -'.  Simplify test construction.
>       Work even if the underyling system attaches ACLs to new dirs.
> @@ -71,11 +73,11 @@ for p in empty -p; do
>  
>      mkdir $p $mode parent/sub || fail=1
>  
> -    perms=`ls -ld parent | sed 's/ .*//'`
> +    perms=`ls -ld parent | sed 's/ .*//; s/+$//'`

I had some further thoughts about this.  Forking is expensive in cygwin,
so I was experimenting with spawning one less process by doing:

perms=`stat -c %A parent`

It appears that only ls is appending the '+' for ACLs; should stat also be
given a format character for printing whether a file has additional
permissions?  For the purposes of the testsuite, making it separate from
%A is nice, because then you don't have to strip a trailing '+' (or any of
the other trailing information in a long ls listing) when determining a
file's permissions.

$ ls -ld .
drwxr-xr-x+ 14 eblake None 0 May  2 06:25 .
$ stat -c %A .
drwxr-xr-x

stat(1) doesn't appear to be in any standards, and coreutils stat has a
different set of options than either the zsh builtin or the FreeBSD
version (http://tautology.org/software/man/stat).  Nice things about the
FreeBSD version that coreutils does not have:
- -F: display like `ls -lTF'
- -n: supress newline between files
- -q: supress errors from stat/lstat
- -f format: (similar to coreutils -c without -f)
   allows flags and width between % and character
   %p file type and permissions
   %l (similar to coreutils %h)
   %r device number for character and block devices
   %a (similar to coreutils %x)
   %m (similar to coreutils %y)
   %c (similar to coreutils %z)
   %B inode creation time (not all filesystems support this)
   %z (similar to coreutils %s)
   %k (similar to coreutils %o)
   %f user-defined flags
   %v inode generation number
   %T file type indicator (*/=@|%)
   %Y symlink target
   %Z major,minor on special devices, size on others
   %% single % (undocumented in coreutils)
- -l: display like `ls -lT'
- -r: raw stat field entries (is this like coreutils -t?)
- -s: quote output, suitable for shell variable initialization
- -x: more verbose
- -t timefmt: format dates with input similar to date(1)

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCdiVE84KuGfSFAYARAgZKAJ9d7R7JDCwBf0CibbU6KmMg6jNPWACfbEZs
XSDdPGdLAV2bC/xisN1HlFM=
=nVWv
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]