Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 530416 - sys-process/cronbase: run-crons: rewrite in POSIX shell
Summary: sys-process/cronbase: run-crons: rewrite in POSIX shell
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Cron Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-24 15:53 UTC by Alexander Hof
Modified: 2015-08-04 14:36 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Remove a bashism that fails with *ksh. (diff,507 bytes, patch)
2014-11-24 15:53 UTC, Alexander Hof
Details | Diff
remove a bashism that fails with *ksh (diff,672 bytes, patch)
2014-11-24 18:31 UTC, Alexander Hof
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Hof 2014-11-24 15:53:17 UTC
/usr/sbin/run-crons has a bashism that makes it incompatible with mksh, which is annoying when using it as system shell.
Attached is a simple fix.

Reproducible: Always

Steps to Reproduce:
1. set *ksh as system shell
2. run /usr/sbin/run-crons
Actual Results:  
get syntax error:
run-crons[40]: syntax error: '((' unexpected

Expected Results:  
Run smoothly with other shells, as it does something rather simple.
Comment 1 Alexander Hof 2014-11-24 15:53:57 UTC
Created attachment 390204 [details, diff]
Remove a bashism that fails with *ksh.
Comment 2 Alexander Tsoy 2014-11-24 17:35:29 UTC
What cron daemon do you use?

$ qlist -ICv cronbase
sys-process/cronbase-0.3.3
$ head -n1 /usr/sbin/run-crons 
#!/bin/bash
Comment 3 Alexander Hof 2014-11-24 18:31:50 UTC
Created attachment 390214 [details, diff]
remove a bashism that fails with *ksh

I forgot to change the shebang, here's a new one.
Notice that not all bashisms are replaced, only the one that was incompatible with *ksh.
Comment 4 Alexander Hof 2014-11-24 18:33:01 UTC
(In reply to Alexander Tsoy from comment #2)
> What cron daemon do you use?

dcron
 
> $ qlist -ICv cronbase
> sys-process/cronbase-0.3.3
> $ head -n1 /usr/sbin/run-crons 
> #!/bin/bash

I now changed the shebang.
Comment 5 Alexander Hof 2014-11-24 19:17:23 UTC
(In reply to Alexander Tsoy from comment #2)

oh and about:
 
> $ qlist -ICv cronbase

# equery b /usr/sbin/run-crons
 * Searching for /usr/sbin/run-crons ...
sys-process/cronbase-0.3.3 (/usr/sbin/run-crons)
Comment 6 Alexander Tsoy 2014-11-24 20:00:11 UTC
The question is why run-crons gets processed by mksh on your system. It has /bon/bash in shebang and should work fine.

# grep run-crons /var/tmp/portage/sys-process/dcron-4.5-r1/image/etc/crontab 
*/10 *  * * *  test -x /usr/sbin/run-crons && /usr/sbin/run-crons
Comment 7 Alexander Hof 2014-11-24 20:09:42 UTC
(In reply to Alexander Tsoy from comment #6)
> The question is why run-crons gets processed by mksh on your system. It has
> /bon/bash in shebang and should work fine.
> 
> # grep run-crons /var/tmp/portage/sys-process/dcron-4.5-r1/image/etc/crontab 
> */10 *  * * *  test -x /usr/sbin/run-crons && /usr/sbin/run-crons

I see now. It gets processed by bash, that's not the problem. I _wanted_ it to run with mksh. And I think the proposed change to make it possible is so marginal that it shouldn't be a problem to adopt it.
Apologies for the misunderstanding.

If it is desired I can try to remove the remaining bashisms to make #!/bin/sh more justifiable.
Comment 8 Alexander Tsoy 2014-11-24 20:19:50 UTC
(In reply to Alexander Hof from comment #7)

Thanks for clarification. It wasn't clear from the bug description.
Comment 9 SpanKY gentoo-dev 2015-07-21 09:34:49 UTC
run-crons is clearly a bash script:
$ head -1 /usr/sbin/run-crons                                  
#!/bin/bash

forcing it to run under other shells is a user error.  fixing a few random constructs to make it readable by other shells (like ksh derivatives) is a dead end imo -- people will still write & test only under bash.

the only real route here is to convert it entirely to POSIX shell and use #!/bin/sh as the shebang.  i don't think that process should be *too* hard.
Comment 10 SpanKY gentoo-dev 2015-07-22 01:22:36 UTC
and i've rewritten it in POSIX shell locally now
Comment 11 SpanKY gentoo-dev 2015-07-23 02:57:49 UTC
should be all set now in the tree; thanks for the report!

Commit message: Rewrite run-crons in POSIX shell
http://sources.gentoo.org/sys-process/cronbase/cronbase-0.3.6.ebuild?rev=1.1
http://sources.gentoo.org/sys-process/cronbase/files/run-crons-0.3.6?rev=1.1
Comment 12 Alexander Hof 2015-08-04 14:36:48 UTC
(In reply to SpanKY from comment #11)
> should be all set now in the tree; thanks for the report!
> 
thanks for fixing!