jutty,
@jutty@bsd.cafe avatar

After a while trying to understand if either ksh or zsh provided a way to prevent taking strings and undefined variables as 0 when doing arithmetic evaluation, there seems to be no feature specifically for it, sadly.

Closest is using set -o nounset (ksh) and setopt no_unset (zsh) to prevent undefined variables from evaluating to zero. If a "string" contains only numbers, a dot and whitespace, it will be treated as a number. Also, if it only contains the name of any other variable and whitespace, it evaluates to that.

Not that I expected shell languages to provide accurate arithmetic.

As a bonus though, it was cool learning about ksh's compound variables, force_float option and especially discipline functions.

  • @me@mysmallinstance.homelinux.org avatar
    me
  • All
  • Subscribed
  • Moderated
  • Favorites
  • programming
  • kavyap
  • ngwrru68w68
  • tacticalgear
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • thenastyranch
  • Youngstown
  • Durango
  • slotface
  • everett
  • vwfavf
  • rosin
  • anitta
  • Leos
  • khanakhh
  • GTA5RPClips
  • cisconetworking
  • InstantRegret
  • ethstaker
  • osvaldo12
  • tester
  • provamag3
  • modclub
  • cubers
  • normalnudes
  • megavids
  • JUstTest
  • All magazines