News for hackers. Stuff that matters.
Re:Instant replay: Debugging C and C++ programs with rr by 1vuio0pswjnm7 on Tuesday May 04, 2021 @03:38AM (#27034893)
Somehow I never use tee because sed allows the same thing, with up to seven files. Sometimes I do not have a tee in the userland (yet), but in every toolchain I always have sed.

   echo 1 | sed w/proc/sys/kernel/perf_event_paranoid
Re:Instant replay: Debugging C and C++ programs with rr by chrismorgan on Tuesday May 04, 2021 @04:13AM (#27035124)
Huh. Never come across a *nix machine without either. Both are part of POSIX since at least 2001 (I don’t have ready access to specs from older).
Re:Instant replay: Debugging C and C++ programs with rr by 1vuio0pswjnm7 on Tuesday May 04, 2021 @04:33AM (#27035251)
I build systems from source. Sometimes I do things before installing a full userland. (Sometimes I never do install a full userland, opting for a smaller customised one.) I have learnt to use what is available on BSD install media and in BSD toolchains. sed is popular choice utility for BSD toolchains. tee, not so much.
Re:Instant replay: Debugging C and C++ programs with rr by chrismorgan on Tuesday May 04, 2021 @06:13AM (#27035812)
I see I was correct in guessing that you weren’t dealing with Linux, since that’s almost certain to use GNU userland, and there tee is part of coreutils, and good luck getting anything done without coreutils. (GNU sed is its own thing rather than being part of coreutils or any other *utils bundle. I don’t know why this is.)

I’m still a little surprised to hear of tee not being present when sed is, but I’m not familiar with BSD. Maybe they care even less about POSIX than I would have expected?

I’ve been a little bit embittered against sed because of the differences across platforms. As usual, the version that comes out of the box on macOS is ancient, for licensing reasons, and the distinction has caused me grief too many times. I seem to recall having to give up on using sed for in-place regular expression replacement in a file when I was only caring about Linux, Linux under WSL 1 and macOS, and ended up using a fairly convoluted Perl one-liner instead (something like -plni.bak followed by rm foo.bak, because -i sans extension broke under WSL 1). Cross-platform operation is trickier than I wish it were!

Re:Instant replay: Debugging C and C++ programs with rr by 1vuio0pswjnm7 on Tuesday May 04, 2021 @07:03AM (#27036199)
I prefer ed for so-called "in-place" editing, not "sed -i". I am always using tmpfs anyway and it makes little difference to me if I can see the temporary file created or whether it is effectively hidden. Even NetBSD has added "-i" to sed now, and coreutils does not include ed. I do not see such moves as "progress" but that's just me.

If MacOS sed has "-a" then something like

   sed -na 's/a/b/;H;$!d;g;w'file file
should approximate "-i" (but without a temp file). The catch is it will leave a blank line at the top.
Re:Instant replay: Debugging C and C++ programs with rr by carlmr on Tuesday May 04, 2021 @04:30AM (#27035227)
Yeah, similarly surprised, since I always do sudo tee.
Re:Instant replay: Debugging C and C++ programs with rr by bicolao on Tuesday May 04, 2021 @06:11AM (#27035794)
Wow, I was so confused because I thought you gave sed a path, but you gave it a command

    w<path>
TIL.
Re:Instant replay: Debugging C and C++ programs with rr by dataflow on Tuesday May 04, 2021 @04:40AM (#27035317)
I think you meant to sudo?