astrid,
@astrid@fedi.astrid.tech avatar

bash is so fucking funny. the fact that [ is a command and if [ $a -eq $b ] is actually calling the command [ with args $a -eq $b ] and checking its exit code is so fucking hilarious

like literally run which [ and you get /usr/bin/[

oblomov,
@oblomov@sociale.network avatar

@astrid learning that was crucial to understand how shell scripting actually works. AlthoughTBF most shells have [ as an internal command.

(Recommend using command -v $yourcmd rather than which $yourcmd. It tells you exactly what $yourcmd will run, and e.g. command -v [ gives just [ because it uses the internal one.)

glyph,
@glyph@mastodon.social avatar

@astrid not… quite

$ which [
/bin/[
$ type [
[ is a shell builtin

[ is a command and you can run it, but that's actually too slow, so it doesn't work like that in actual scripts. this is a great thing to remember if anyone tries to tell you that UNIX has an elegant design

astrid,
@astrid@fedi.astrid.tech avatar

@glyph aw darn okay i stand corrected

ok but the existence of an executable named [ is really funny tho

glyph,
@glyph@mastodon.social avatar

@astrid if anything this only makes it funnier, tbh

glyph,
@glyph@mastodon.social avatar

@astrid on BSD (and macOS) the difference is subtle, but on a GNU system, like any Linux with GNU coreutils, running /usr/bin/[ --help will spit out a wall of text whereas [ --help does nothing. They can't help themselves

chriscoreline,
@chriscoreline@todon.nl avatar

@astrid i hate this entire thing and im going to go have a cry about it.

reinhilde,

@astrid it’s usually a symlink to /bin/test

astrid,
@astrid@fedi.astrid.tech avatar

@reinhilde yea but you can’t just [ $a -eq $b that’s gonna give you [: ']' expected whereas if you ran test you can

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • mdbf
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • osvaldo12
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • InstantRegret
  • tacticalgear
  • provamag3
  • ethstaker
  • cisconetworking
  • modclub
  • tester
  • GTA5RPClips
  • cubers
  • everett
  • normalnudes
  • megavids
  • Leos
  • anitta
  • JUstTest
  • lostlight
  • All magazines