GNU bug report logs - #61708
28.2; file-modes-symbolic-to-number inconsistency

Previous Next

Package: emacs;

Reported by: Thierry Volpiatto <thievol <at> posteo.net>

Date: Wed, 22 Feb 2023 13:59:02 UTC

Severity: normal

Found in version 28.2

Full log


View this message in rfc822 format

From: Thierry Volpiatto <thievol <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: schwab <at> suse.de, Gregory Heytings <gregory <at> heytings.org>, 61708 <at> debbugs.gnu.org
Subject: bug#61708: 28.2; file-modes-symbolic-to-number inconsistency
Date: Thu, 23 Feb 2023 07:00:55 +0000
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Cc: Andreas Schwab <schwab <at> suse.de>, 61708 <at> debbugs.gnu.org
>> Date: Wed, 22 Feb 2023 21:40:21 +0000
>> From: Gregory Heytings <gregory <at> heytings.org>
>> 
>> 
>> >>> How one convert the output of (nth 8 (file-attributes "/home/user")) 
>> >>> to numeric mode?
>> >>
>> >> (file-modes "/home/user")
>> >
>> > Yes, thanks I know this one, what I want to convert is e.g. "-rwxr-x---" 
>> > to number.
>> >
>> 
>> (defun symbolic-mode-to-number (mode)
>>    (string-to-number
>>     (replace-regexp-in-string
>>      "[^0]" "1"
>>      (string-replace "-" "0" mode))
>>     2))
>
> Maybe we should have a knob in file-attributes or in
> file-attribute-modes to return the modes as either a number or in
> symbolic form suitable for file-modes-symbolic-to-number?

That's a good idea.

-- 
Thierry
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 2 years and 116 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.