From: Kevin Daudt <me@ikke.info>
To: Derrick Stolee <stolee@gmail.com>
Cc: "Martin Ågren" <martin.agren@gmail.com>,
"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH] maintenance: specify explicit stdin for crontab
Date: Tue, 30 Mar 2021 19:12:35 +0200 [thread overview]
Message-ID: <YGNcA3paBeZ8mYVP@alpha> (raw)
In-Reply-To: <25ea6f26-c829-f63f-77a1-11a28bbe7fc0@gmail.com>
On Tue, Mar 30, 2021 at 08:02:22AM -0400, Derrick Stolee wrote:
> On 3/30/2021 1:41 AM, Martin Ågren wrote:
> > On Mon, 29 Mar 2021 at 23:23, Kevin Daudt <me@ikke.info> wrote:
> >>
> >> There are multiple crontab implementations that require stdin for
> >> editing a crontab to be explicitly specified as '-'.
>
> Thank you for reporting this, especially with a patch!
>
> However, I'm not sure about this adding of '-' being something that
> crontab ignores so commonly. My Ubuntu machine reports this:
>
> $ crontab -e -
> crontab: usage error: no arguments permitted after this option
> usage: crontab [-u user] file
> crontab [ -u user ] [ -i ] { -e | -l | -r }
> (default operation is replace, per 1003.2)
> -e (edit user's crontab)
> -l (list user's crontab)
> -r (delete user's crontab)
> -i (prompt before deleting user's crontab)
>
> Is there a way we could attempt writing over stdin, notice the
> failure, then retry with the '-' option?
We do not use -e to edit, we run `crontab` and provide the contents to
stdin. `crontab -e` just opens the crontab in the users editor, which
would work with busybox as well, but that's not what's being done here.
>
> >
> > [...]
> >
> >> --- a/t/helper/test-crontab.c
> >> +++ b/t/helper/test-crontab.c
> >> @@ -17,7 +17,7 @@ int cmd__crontab(int argc, const char **argv)
> >> if (!from)
> >> return 0;
> >> to = stdout;
> >> - } else if (argc == 2) {
> >> + } else if ((argc == 3 && !strcmp(argv[2], "-")) || argc == 2) {
> >> from = stdin;
> >> to = fopen(argv[1], "w");
> >
> > Would it make sense to make this
> >
> > } else if (argc == 3 && !strcmp(argv[2], "-")) {
> >
> > in order to make this test-tool as picky as possible and to only accept
> > the kind of usage we want to (well, need to) use? The tests as they
> > stand would still pass, which I think argues for us not really needing
> > that "argc == 2".
> >
> > This would be followed by
> >
> > } else
> > return error("unknown arguments");
> >
> > which wouldn't be super helpful if you forgot the "-", but helpful
> > enough for an internal test-tool, I guess.
> >
> > Speaking of usage and hints, there's "Usage: ..." in a comment at the
> > top of this file. It should probably be updated either way.
>
> I agree with Martin's review here, too.
Yes, I agree too, was already contemplating that.
>
> Thanks,
> -Stolee
next prev parent reply other threads:[~2021-03-30 17:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-29 21:09 [PATCH] maintenance: specify explicit stdin for crontab Kevin Daudt
2021-03-30 5:41 ` Martin Ågren
2021-03-30 12:02 ` Derrick Stolee
2021-03-30 17:12 ` Kevin Daudt [this message]
2021-03-30 19:32 ` Derrick Stolee
2021-03-30 17:43 ` Todd Zullinger
2021-03-30 19:38 ` Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YGNcA3paBeZ8mYVP@alpha \
--to=me@ikke.info \
--cc=git@vger.kernel.org \
--cc=martin.agren@gmail.com \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).