Hello,

I would like to propose a new --mode=MODE option for touch.

The option specifies the permissions used when touch creates a file that
does not already exist.

For example:

touch --mode=0755 script.sh
touch --mode=0600 private-file

The behavior is:

   - MODE is interpreted as an octal file mode.
   - The mode applies only when a new file is created.
   - Existing files retain their current permissions.
   - The resulting permissions remain subject to the process umask.
   - Normal touch behavior is unchanged when --mode is not specified.

The motivation is to allow callers to control permissions at file creation
time instead of requiring a separate chmod operation afterward.

I have included implementation changes, documentation, and tests in the
attached patch.

The patch is also available in my public Coreutils fork on the
touch-mode-option branch.

Feedback on the interface and behavior would be appreciated.

Best regards,
Saher Mohamed

Reply via email to