Учи баш, учи баш
May. 1st, 2022 12:31 pmВот, я опять узнал что-то новое.
! command позволяет инвертировать код возврата. Казалось бы, тривиально, но с учётом мнения readline по поводу '!' у меня было табу насчёт восклицательных знаков в шелле.
! command позволяет инвертировать код возврата. Казалось бы, тривиально, но с учётом мнения readline по поводу '!' у меня было табу насчёт восклицательных знаков в шелле.
no subject
Date: 2022-05-01 02:16 pm (UTC)OMG. It's complicated, is not it? How do they keep 42? Seems like the script is compiled (and optimized) before running. Weird, weird. Not that I don't like it. Enjoying it.
no subject
Date: 2022-05-01 03:18 pm (UTC)Compiled? Not necessarily, IMO they have some sort of expression context (kinda like Perl, after all it is from the same era :)). So, a '! ! 42' evaluates in some sort of numeric context (there is an implicit assignment to $!); in the context of 'if .. then' expression it is evaluated as boolean. Makes sense, huh!?
no subject
Date: 2022-05-01 06:35 pm (UTC)Yes, but one had to reduce
! !to nop, otherwise how does it know that! 0should be 42?