Re: Wishing rmdir had a prompt

2019-10-23 Thread sunnycemetery

On 2019-09-02 17:22, Bernhard Voelker wrote:
 Just recently I've been asked (off-list) why src/true.c needs to have  
 80+ lines while 3 lines would be enough.


This piqued my curiosity.  Obvious comment header, localization, and  
--{help,version} fluff aside, I was not aware of the GNU-specific fringe  
case, outlined on the info page as steps to force true to produce a false  
return value.  It has been added to my list of party gags.




Re: Enhancement request to GNU date

2019-10-23 Thread Stephane Chazelas
2019-10-17 14:22:53 +0300, Yair Lenga:
[...]
> Would like to ask that you will consider the following extension to 'date'.
> The change will make it easier to perform basic date manipulations in
> scripts.
> 
> The request is to add the following 'suffixes' to the date (similar to the
> way relative dates are supported):
> * EOM - last date of the month
> * BOM - beginning of the month
> * EOY - last date on the year
> * BOY - first date of the year
> * prev EOM - last day previous month
> * next EOM - last day next month
> * prev EOY, next EOY - ditto.
> 
> While all of the constructs can be achieved today, they require multiple
> calls to date, with cumbersome formatting. Having those as "built-in" will
> make it easier to perform date manipulations.
> 
> Consider getting the number of days in the previous month
> Now:
> INPUT=2019-02-28
> date +'%d' -d "$(date +'%Y-%m-01' -d "$INPUT") -1day"
> Using PREV EOM
> date +'%d' -d "$INPUT prev EOM"
> 
> Thank you for taking time to look into this request. Any feedback is
[...]

For the record, with the ast-open implementation of date (like
the ksh93 date builtin if built as part of ast-open):

$ ast-date -d 'this month, yesterday' +%d
30
$ ast-date -d 'final day in last month' +%d
30
$ ast-date -d 'final day in december this year' +%F
2019-12-31
$ ast-date -d '1st day in january' +%F
2019-01-01

See more examples of what it supports at 
https://github.com/att/ast/blob/ksh93u/src/cmd/tests/date.dat

-- 
Stephane




Re: feature request: self join from stdin

2019-10-23 Thread Bernhard Voelker
On 2019-10-21 08:28, Rasmus Borup Hansen wrote:
> [...] e.g. this hangs on my machine:
> 
> mkfifo fifo && seq -s , 2 | tee fifo | join -j2 - fifo | paste -s && rm 
> fifo

okay, then better use a regular file, and join that with itself:

  $ seq -s , 2 > x

  $ join -j2 x x  | paste -s
   1,2,3,4,5,6,[...]

Have a nice day,
Berny