News for hackers. Stuff that matters.
Re:Shit – An implementation of Git using POSIX shell by Hello71 on Wednesday February 12, 2020 @12:50PM (#22310925)
what the fuck? I specified POSIX alternatives to non-POSIX uses in the code. only one feature, brace expansion, is not POSIX, so I specifically did not recommend its use.
Re:Shit – An implementation of Git using POSIX shell by acqq on Wednesday February 12, 2020 @04:51PM (#22313189)
Th specific part that I understood as your argument for non-POSIX solutions:

"'for x in $y; do printf "$a%s$b" "$x"; done' is equivalent to 'printf "$a%s$b" $y' (assuming neither a nor b contain format specifiers). similarly, 'for i in {1..100}; do printf "$a"; done' is equivalent to 'printf "$a%s.0" {1..100}'. unfortunately, brace expansion is not POSIX, but these are both significantly more efficient (both in code size and execution time) than the loop methods."

I didn't understand why you write that part at all, considering the goals of the program we discuss (which is to demonstrate some git primitives in POSIX compliant shell code).

Re:Shit – An implementation of Git using POSIX shell by Hello71 on Thursday February 13, 2020 @12:00PM (#22319271)
'for x in $y; do printf "$a%s$b" "$x"; done' is used in the code already. I am proposing that it be changed to 'printf "$a%s$b" $y', which is also POSIX compliant, shorter (even including a comment), and faster. I included the part about brace expansion as a side note, not proposing that it be used.
Re:Shit – An implementation of Git using POSIX shell by acqq on Thursday February 13, 2020 @03:46PM (#22321266)
> 'printf "$a%s$b" $y', which is also POSIX compliant, shorter

Yes, indeed, thanks for pointing that, it's documented:

"The format operand shall be reused as often as necessary to satisfy the argument operands."

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/p...

Re:Shit – An implementation of Git using POSIX shell by acqq on Wednesday February 12, 2020 @02:34PM (#22311967)
I’m sorry if I misunderstood you. I’m indeed interested in what from all you wrote is then what you would suggest to be changed, as I also looked at his code and also read here that it was done in short time so I also believer there are possibilities for improvement. Specifically, reimplementing sha calculation itself should be a non goal, in my opinion. Just that the .sh code itself works on all POSIX shells, not that the whole system has to be POSIX only: calculating sha in shell is surely not the point of demonstrating how git works.