przemoc

Poland

przemoc.net

Age: 29

Realist and pragmatist. Strong-willed and strong-minded. Sometimes taciturn, sometimes loquacious. FLOSS enthusiast but still using Windows. Stuck in the endless process of becoming a Linux wizard.

2d
revised My keyboard has no "media" keys; can I control media without them?
Improvements and link fixes, most notably autohotkey.com -> ahkscript.org, which I should have done long time ago. AutoHotkey_L has become the official branch three years ago, so there is no point in mentioning it explicitly. Linux part is still not here (my apology), so it's better to remove it.
Jul
31
comment The best way to ensure only 1 copy of bash script is running?
Important update about trap fn EXIT. It must be supported by any POSIX-compliant shell, as I already wrote 6 months ago, but the thing is it's differently implemented. We simply want to have fn be executed when script ends (be it normal exit or invoked via some signal). EXIT works that way in bash or ksh, but not in zsh or dash for instance. That's why I originally went with bash despite having otherwise quite clean sh script. I relearned this trap issue a few months ago (I have to finally start blogging to ease relearning things), but forgot to write about it here as well, sorry for that!
Jul
25
awarded Supporter
Jul
25
awarded Autobiographer
Jun
14
awarded Supporter
May
30
awarded Notable Question
May
6
awarded Guru
May
3
awarded Yearling
May
3
awarded Yearling
Feb
23
awarded Yearling
Feb
23
awarded Yearling
Jan
31
comment How to remove last directory from a path with sed (not using dirname)?
@ChrisF Huh? Why you wrote so? echo a.b/c.d/e.f | sed 's,/*[^/]\+/*$,,' returns a.b/c.d or it doesn't in your sed version? My regexp has nothing to do with . at all.
Jan
31
comment The best way to ensure only 1 copy of bash script is running?
@GeorgeYoung Removing lock file at the end of script only if immediate exclusive lock succeeds (after earlier unlocking) is for the case of other script instance patiently waiting to obtain exclusive or shared lock (i.e. using exlock or shlock), because when it finally starts, then previous instance shouldn't remove the file.
Jan
31
comment The best way to ensure only 1 copy of bash script is running?
@overthink only literal number next to > is considered as file descriptor number, so without eval there exec tries to execute binary called 99 (or whatever else is put in $LOCKFD). It's worth to add that some shells (like dash) have a bug that requires fd number to be single digit. I chose high fd number to avoid possible collisions (they depend on the use case, though). I went with BASH also because of convenient EXIT condition in trap IIRC, but it looks I was wrong, as it is part of POSIX shell.
Jan
31
comment The best way to ensure only 1 copy of bash script is running?
@EdouardThiel Yeah. I actually try to avoid any bashisms, but your basename equivalent is not a BASH thing, it's POSIX thing, so it's fine indeed. BTW I also don't use backticks anymore and prefer much more sane $() notation. Why is $(...) preferred over backticks?
Jan
9
awarded Nice Answer
Dec
31
awarded Yearling
Dec
31
awarded Yearling
Nov
13
awarded Popular Question
Sep
30
awarded Explainer
1 2 3 4 5