Skip to content

HomeSetup Developer Handbook

Standard-Tools

Table of contents

Text utilities

__hhs_highlight

usage: __hhs_highlight <text_to_highlight> [filename]

  Notes:
    filename: If not provided, stdin will be used instead.
Purpose

Highlight words from the piped stream.

Returns

0 on success; non-zero otherwise.

Parameters
  • $1 Required : The word to highlight.
  • $2 Piped : The piped input stream.
Examples

__hhs_highlight MIT LICENSE.md

Output

The MIT License (MIT)
in the Software without restriction, including without limitation the rights
copies of the Software, and to permit persons to whom the Software is
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

__hhs_json_print

usage: __hhs_json_print <json_string>
Purpose

Pretty print (format) JSON string.

Returns

0 on success; non-zero otherwise.

Parameters
  • $1 Required : The unformatted JSON string.
Examples

__hhs_json_print '[{"name":"my name","age":30}]'

Output

[
  {
    "name": "my name",
    "age": 30
  }
]

__hhs_ascof
usage: __hhs_ascof <string>
Purpose

Convert string into it's decimal ASCII representation.

Returns

0 if the representation was displayed; non-zero otherwise.

Parameters
  • $1 Required : The string to convert.
Examples

__hhs_ascof Hello

Output

Dec: 72 101 108 108 111
Hex: 48  65  6c  6c  6f
Str: Hello

__hhs_utoh
usage: __hhs_utoh <4d-unicode...>

  Notes:
    - unicode is a four digits hexadecimal number. E.g:. F205
    - exceeding digits will be ignored
Purpose

Convert unicode to hexadecimal.

Returns

0 if the unicode was successfully converted; non-zero otherwise.

Parameters
  • $1..$N Required : The unicode values to convert.
Examples

__hhs_utoh f123 f133

Output

[Unicode:'\uf123']
  Hex => \xef\x84\xa3
  Icn =>   Oct => \357\204\243

[Unicode:'\uf133']
  Hex => \xef\x84\xb3
  Icn =>   Oct => \357\204\263

__hhs_errcho

usage: __hhs_errcho <app_name> <message>
Purpose

Echo a message in red color into stderr.

Returns

0 on success; non-zero otherwise.

Parameters
  • $1 Required : The application name.
  • $2..$N Required : The message to be echoed.
Examples

✘ Fatal: bash  Invalid parameters

Output

error: Invalid parameters