tech-userlevel archive

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

Re: crontab(1) using stdin



On Tue, Oct 29, 2024 at 07:11:10PM +0100, Edgar Fuß wrote:
> > Those are not inconsistent, unless SUS specifies other behaviour for
> > the case of a bare -, or NetBSD's version doesn't read from stdin when
> > no (pseudo-)filename is given.
They are, POSIX says something like
  97851  STDIN
  97852  The standard input shall be used if a file operand is '−' and the implementation treats the '−'
  97853  as meaning standard input. Otherwise, the standard input shall not be used.
if it allows implementations to us - to mean stdin.

XCU crontab doesn't have this stanza.

> NetBSD's version complains if no filename is given.
POSIX.1-2024, XCU, crontab says:
  90910  SYNOPSIS
  90911  crontab [file]
  90911  crontab [-e|-l|-r]

  90913  DESCRIPTION
  90915                                                          The new crontab entry can be input by
  90916  specifying file or input from standard input if no file operand is specified, or by using an editor,
  90917  if −e is specified.

  90944  OPERANDS
  90945  The following operand shall be supported:
  90946  file The pathname of a file that contains specifications, in the format defined in the
  90947        INPUT FILES section, for crontab entries.

The standard is very clear that
"crontab"   means "crontab /dev/stdin" and
"crontab -" means "crontab ./-".

OTOH this fucking sucks, both ergonomically when you just nuked
your crontab by accident, and especially on implementations where "-"
does tend to mean the standard input stream.

Other implementations don't really agree with this, either:
sd-cron and the debian derivative of vixie-cron both have
"crontab" = "crontab -" = "crontab /dev/stdin".

If NetBSD "crontab" errors with 
"use crontab - to replace your crontab from the standard input stream"
then that's an improvement over both the standard and the status quo IMO

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index