Skip to content

Strings

Index

strings::is_empty

Return true if the string is empty (zero length).

Arguments

  • $1 (string): to test

Exit codes

  • 0: if true
  • 1: if false

strings::is_not_empty

Return true if the string is non-empty (at least one character).

Arguments

  • $1 (string): to test

Exit codes

  • 0: if true
  • 1: if false

strings::is_blank

Return true if the string is empty or contains only whitespace characters.

Arguments

  • $1 (string): to test

Exit codes

  • 0: if true
  • 1: if false

strings::is_not_blank

Return true if the string contains at least one non-whitespace character.

Arguments

  • $1 (string): to test

Exit codes

  • 0: if true
  • 1: if false

strings::assert_empty

Die if the string is not empty (zero length).

Arguments

  • $1 (string): to test

strings::assert_not_empty

Die if the string is empty (zero length).

Arguments

  • $1 (string): to test

strings::assert_blank

Die if the string contains any non-whitespace characters.

Arguments

  • $1 (string): to test

strings::assert_not_blank

Die if the string is empty or contains only whitespace characters.

Arguments

  • $1 (string): to test

strings::trim

Print the string with leading and trailing whitespace removed. Output: stdout — trimmed string

Arguments

  • $1 string

strings::ensure_trailing_slash

Print the string with a trailing slash appended if it does not already end with one. Output: stdout — string guaranteed to end with '/'

Arguments

  • $1 string