Permissions
rwx_to_octal¶
Convert a symbolic rwx permission string to its octal representation. Accepts 9-char (rwxr-xr-x) or 10-char (-rwxr-xr-x) input. Handles setuid (s/S), setgid (s/S), and sticky (t/T) bits.
Example¶
rwx_to_octal rwxr-xr-x # => 755
rwx_to_octal rwsr-xr-x # => 4755
rwx_to_octal -rwxr-xr-x # => 755
Arguments¶
- $1 (string): Symbolic permission string (9 or 10 characters)
Exit codes¶
- 0: Success
- 1: Invalid input
Output on stdout¶
- Octal permission string (3 or 4 digits)
permissions_convert¶
Auto-detect and convert between octal and symbolic permission modes. Delegates to octal_to_rwx() or rwx_to_octal() based on the input format.
Example¶
permissions_convert 755 # => rwxr-xr-x
permissions_convert rwxr-xr-x # => 755
Arguments¶
- $1 (string): Octal mode or symbolic permission string
Exit codes¶
- 0: Success
- 1: Invalid input
Output on stdout¶
- Converted permission representation