Skip to content

Latest commit

 

History

History
120 lines (85 loc) · 3.6 KB

faq.md

File metadata and controls

120 lines (85 loc) · 3.6 KB

FAQ

Why not support other shells?

Ash/Dash/Fish/Tcsh/Xiki and other shells are not supported because there are so many differences with Bash. It is too complex to be compatible with other shells, and benefit limited.

References:

Why not support Zsh?

Although Bash and Zsh are the most prevalent shells in the world and they have similar shell script syntaxes, their builtin commands have many differences. See Differences between Bash and Zsh.

So I think it is better to implement Zsh library in another project.

Why not support Windows system?

It is too complex to be compatible with it, and benefit limited.

Why ./bin/lobash mod not always work?

Many Lobash modules are dependent on variables in current shell environment which are not shareable in sub-shell environments. And the nameref feature not work as command arguments.

It creates new sub-shell when invoke ./bin/lobash. So many Lobash modules will not work.

Why source script, not execute command?

Read this answer to know the difference between executing and sourcing of scripts.

Bash is outdated!

No. I have found that most Linux distributions still use Bash as default/login shells.

Although most Linux distributions use Bash v4.3, you can upgrade Bash easily and it is backward compatible.

What is the different between echo true/false and return 0/1?

Read this document: How to return a Boolean value.

Because we set the set -o errexit and shopt -s inherit_errexit, l.is_* will lead to process exit. For example,

#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail
shopt -s inherit_errexit

local r
# l.is_file will return 1 and lead to process exit
r=$(l.is_file wow)
echo "r=$r"

All Lobash Condition modules are robust enough. It provides two implements for different usages.

So use l.is_file.s instead.

#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail
shopt -s inherit_errexit

local r
r=$(l.is_file.s wow)
# process will go on
echo "r=$r"

The right way to use l.is_* is in if condition.

#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail
shopt -s inherit_errexit

if l.is_file wow; then
  echo "Is file"
else
  echo "Not file"
fi

sed: -e expression: Invalid character class name

If you see sed: -e expression #1, char 33: Invalid character class name when building, it means you are using GNU-sed on MacOS. Invoke which sed to see the path of sed. To solve the problem, you should use BSD-sed on MacOS, or GNU-sed on Linux.