Elektrine lite

← Feed

@fanf@mendeddrum.org

2026-07-22 20:42 UTC

from my link log — What exactly was the point of [ “x$var” = “xval” ]? https://www.vidarholen.net/contents/blog/?p=1035 saved 2021-04-12 https://dotat.at/:/KWNJ4.html

Replies (2)

  • @hyc@mastodon.social 2026-07-22 21:02

    @fanf@mendeddrum.org an interesting historical dive, but I'm not convinced that the practice can safely be left behind. Nor do I understand why one would go to the trouble. It's not like testing "x$var" = "xval" is more expensive or less legible than omitting the 'x'.

    Open ##5101511

  • @simon3270@fosstodon.org 2026-07-22 21:21

    @fanf@mendeddrum.org I've been writing shell scripts for 50 years, and still use the "x-hack" (muscle memory!). As mentioned in the comments, the main use was for testing empty variables. The hack shouldn't be dismissed too readily - there are still commercial systems running with ancient shells where the hack is still needed. Even as various Bourne-style shells were fixed, you still needed the hack to write portable scripts where you didn't know which specific shell would be used to run it. Vive la "x"!

    Open ##5101515