icy / pacapt

An ArchLinux's pacman-like shell wrapper for many package managers. 56KB and run anywhere.
Other
958 stars 69 forks source link

Switch the requirement for bash to POSIX shell instead #149

Closed LaszloGombos closed 3 years ago

LaszloGombos commented 3 years ago

Would it be possible to switch to POSIX shell instead of bash ?

For example alpine linux does not come with bash preinstalled (comes with busybox). This means that the environment needs to be bootstrapped with the native package manager first "apk add bash" before pacapt can be used. Huge fan of the project, just wanted to point out this are for potential improvement.

cuonglm commented 3 years ago

FYI, busybox sh is not a POSIX shell, though.

icy commented 3 years ago

@LaszloGombos Thanks for using our pacapt and for your suggestion.

I believe the current script has some non-POSIX feature. Porting the script to POSIX shell It's quite possible, though we need to update quite a lot of (its) scripts. The tool also requires grep/awk. I'm not sure about busybox though. I think the need is to address your runtime environment. For that, at the moment, you may want to look at the rust port by @rami3l (https://github.com/rami3l/pacaptr)

rami3l commented 3 years ago

@icy Thanks for having mentioned my port!

According to my observation, people seem to go back and forth between pacapt and pacaptr due to the fact that the scopes of the two projects are already slightly different.

Maybe it's time to clarify those differences somewhere, so that people can make a better choice :)

PS: What I have in mind for now:

I'm still bad at bash scripting :(

icy commented 3 years ago

@rami3l You're welcome. And thanks for your comparison. I'm happy to see your tool has got some success. That's how open source things are working :)

Regarding homebrew I also have seen some new updates, but I don't use them heavily to get them correctly. Do you have a link to the new homebrew features that I can have a look?

I'd like to focus on stability of pacapt and on having more smoke tests for them. I'm a little burnt out today though :(

I'm happy to see you're good (or better) at bash now;) I actually gain a lot of money thanks to bash scripting :D In my current work, I wrote a 600-line tool in Bash + Golang which can have all cool features -for of a very popular 35k-line golang tool , and even more ^.^

rami3l commented 3 years ago

@icy Thanks! Actually I'm using pacaptr kind of as my Rust playground right now, trying to add into it all sorts of things as I see fit.

In short, homebrew is eliminating its cask subcommand. For example, what once should be done with brew cask install now simply goes with brew install (that was what I wanted from pacapt: automatic cask detection).

Sadly I don't believe that homebrew has an all-in-one changelog for this. For what the homebrew module should look like right now, however, you can look at my module.

Here's an example (please note that you don't need to run brew cask uninstall even if you're uninstalling a cask):

/// R removes a single package, leaving all of its dependencies installed.
async fn r(&self, kws: &[&str], flags: &[&str]) -> Result<()> {
    Cmd::new(&["brew", "uninstall"])
        .kws(kws)
        .flags(flags)
        .pipe(|cmd| self.run_with(cmd, Default::default(), &STRAT_PROMPT))
        .await
}

Don't worry if you don't know much about rust: you can do exactly what I did when I read your bash!

I believe you at least know that we are running brew uninstall [kws] [flags], and with only this kind of info it's already possible to rewrite the whole bash module I believe. Sadly since I'll be having my finals in the following week, my availability might be limited. The .run_with() part is my creation in order to make prompt behaviors and other stuff more coherent.

I've also been wondering if we can share some smoke tests (which, as I understand it, is really important to both projects but I just got the basics; your test for debian seems complete but not quite with the others) in the form of json, yaml or something like that. We can simply provide a Python (or Golang or anything you like) version to do the test for pacapt on your side with GitHub Actions, and on my side I'll probably use Rust for testing, but the point is that we can share the config file. How does that sound?

PS: This reply is already off-topic. I suggest that you enable the discussions sector of this repo, and let's go on with our discussion over there.

icy commented 3 years ago

@rami3l

Regarding the homebrew

Thanks a lot for your explaination. I also saw the same note about the deprecation of cask somehwere, and at that time (and now) I thought the script needed to deal with the compatibility issue (two versions of homebrew, one with cask and one without it). To be honest, the case of homebrew is quite exceptional. But of course, I think pacapt needs to manage some time to get new feature onboarded.

Regarding the tests

As you can see I wrote a simple Ruby script to convert the test .txt data into shell:

Those tests are designed to run within container environment (ubuntu, debian images,...), as to me, in this case, it's more important to think as an end-user (e.g, docker container user) than a tool author. If you think there is any place we can share some way to design tests for both projects that'd be great, but let's start new thread.;)

Regarding the unbalance of tests: yes I work on apt-based system most of the time, and a bit slitaz stuff. For other thing, I'd expect some contribution from the community (tests or bug report). Sometime in the past I was expecting some perfect thing, but I know that I've burnt out a bit, so it's as we can see now ;)

icy commented 3 years ago
`shellcheck` POSIX logs (`pacapt-2.4.4`)

```bash In pacapt line 225: local _pacman ^-----------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 237: [[ "$(uname)" == "SunOS" ]] && _PACMAN="$_pacman" && return ^-------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 276: [[ -z "$_PACMAN" ]] || return ^-----------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 279: if [[ -x "/usr/bin/pacman" ]]; then ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 280: $GREP -q "${FUNCNAME[0]}" '/usr/bin/pacman' >/dev/null 2>&1 ^------------^ SC3028: In POSIX sh, FUNCNAME is undefined. ^------------^ SC3054: In POSIX sh, array references are undefined. In pacapt line 281: [[ $? -ge 1 ]] && _PACMAN="pacman" \ ^------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 285: [[ -x "/usr/bin/apt-get" ]] && _PACMAN="dpkg" && return ^-------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 286: [[ -x "/data/data/com.termux/files/usr/bin/apt-get" ]] && _PACMAN="dpkg" && return ^-- SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 287: [[ -x "/usr/bin/cave" ]] && _PACMAN="cave" && return ^----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 288: [[ -x "/usr/bin/dnf" ]] && _PACMAN="dnf" && return ^---------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 289: [[ -x "/usr/bin/yum" ]] && _PACMAN="yum" && return ^---------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 290: [[ -x "/opt/local/bin/port" ]] && _PACMAN="macports" && return ^----------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 291: [[ -x "/usr/bin/emerge" ]] && _PACMAN="portage" && return ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 292: [[ -x "/usr/bin/zypper" ]] && _PACMAN="zypper" && return ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 293: [[ -x "/usr/sbin/pkg" ]] && _PACMAN="pkgng" && return ^----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 295: [[ -x "/usr/sbin/pkg_add" ]] && _PACMAN="pkg_tools" && return ^--------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 296: [[ -x "/usr/sbin/pkgadd" ]] && _PACMAN="sun_tools" && return ^-------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 297: [[ -x "/sbin/apk" ]] && _PACMAN="apk" && return ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 298: [[ -x "/usr/bin/tazpkg" ]] && _PACMAN="tazpkg" && return ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 299: [[ -x "/usr/bin/swupd" ]] && _PACMAN="swupd" && return ^-----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 310: local _opt= ^--------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 311: local _ret=0 ^--------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 339: echo $_opt ^---^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: echo "$_opt" In pacapt line 360: local _opt= ^--------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 361: local _ret=0 ^--------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 381: echo $_opt ^---^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: echo "$_opt" In pacapt line 386: local _args="" ^---------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 387: local _debug= ^----------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 388: local _noconfirm= ^--------------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 400: local _pacman="$1" ^-----------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 401: echo -n "pacapt($_pacman): available operations:" ^-- SC3037: In POSIX sh, echo flags are undefined. In pacapt line 407: echo -n " $O" ^-- SC3037: In POSIX sh, echo flags are undefined. In pacapt line 424: local _tmp_name= ^-------------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 425: local _pacman= ^-----------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 427: _tmp_name="${BASH_SOURCE[0]:-?}" ^------------------^ SC3028: In POSIX sh, BASH_SOURCE is undefined. In pacapt line 428: if [[ "$_tmp_name" == "?" ]]; then ^-----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 437: if grep -Eq -e ":$_pacman[[:space:]]*" <<< "$_SUPPORTED_EXTERNALS"; then ^-- SC1087: Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet). ^-^ SC3011: In POSIX sh, here-strings are undefined. In pacapt line 453: if [[ -z "$_TOPT" ]]; then ^---------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 501: (*) apk add $_TOPT -- "$@" ;; ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: (*) apk add "$_TOPT" -- "$@" ;; In pacapt line 560: shopt -u globstar ^---------------^ SC3044: In POSIX sh, 'shopt' is undefined. In pacapt line 564: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 577: if [[ -n "$*" ]]; then ^-----------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 585: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 602: if [[ -z "$*" ]];then ^-----------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 620: if [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 688: cave resolve $_TOPT "$@" \ ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: cave resolve "$_TOPT" "$@" \ In pacapt line 691: && cave resolve -x $_TOPT "$@" ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: && cave resolve -x "$_TOPT" "$@" In pacapt line 705: if [[ $# -gt 0 ]]; then ^------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 729: conda search "*$@*" ^-- SC2145: Argument mixes string and array. Use * or separate argument. In pacapt line 744: dnf install $_TOPT "$@" ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: dnf install "$_TOPT" "$@" In pacapt line 764: if [[ $# -gt 0 ]]; then ^------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 796: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 798: elif [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 856: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 860: elif [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 873: if [[ -n "$*" ]]; then ^-----------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 882: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 914: if [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 966: apt-get install $_TOPT "$@" ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: apt-get install "$_TOPT" "$@" In pacapt line 999: local pkg prefix cellar ^---------------------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 1007: for package in $cellar/*; do ^-----^ SC2231: Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt . In pacapt line 1008: files=(${package}/*/${pkg/#$prefix\//}) ^-- SC3030: In POSIX sh, arrays are undefined. ^--------^ SC2206: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. ^----------------^ SC2206: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. ^----------------^ SC3060: In POSIX sh, string replacement is undefined. In pacapt line 1009: if [[ -e "${files[${#files[@]} - 1]}" ]]; then ^-- SC3010: In POSIX sh, [[ ]] is undefined. ^------------------------^ SC3054: In POSIX sh, array references are undefined. In pacapt line 1010: echo "${package/#$cellar\//}" ^--------------------^ SC3060: In POSIX sh, string replacement is undefined. In pacapt line 1029: if [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1030: if [[ "$*" == "" ]]; then ^--------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1042: if [ $? -ne 0 ]; then ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. In pacapt line 1047: if [ $? -ne 0 ]; then ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. In pacapt line 1051: if [[ "$@" == "" ]]; then ^--------------^ SC3010: In POSIX sh, [[ ]] is undefined. ^--^ SC2199: Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @). In pacapt line 1052: _die "pacapt: ${FUNCNAME[0]} requires arguments" ^------------^ SC3028: In POSIX sh, FUNCNAME is undefined. ^------------^ SC3054: In POSIX sh, array references are undefined. In pacapt line 1055: for _target in $@; ^-- SC2068: Double quote array expansions to avoid re-splitting elements. In pacapt line 1057: brew rm $_target ^------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: brew rm "$_target" In pacapt line 1059: while [ "$(join <(sort <(brew leaves)) <(sort <(brew deps $_target)))" != "" ] ^--------------------^ SC3001: In POSIX sh, process substitution is undefined. ^------------^ SC3001: In POSIX sh, process substitution is undefined. ^---------------------------^ SC3001: In POSIX sh, process substitution is undefined. ^-------------------^ SC3001: In POSIX sh, process substitution is undefined. ^------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: while [ "$(join <(sort <(brew leaves)) <(sort <(brew deps "$_target")))" != "" ] In pacapt line 1061: brew rm $(join <(sort <(brew leaves)) <(sort <(brew deps $_target))) ^-- SC2046: Quote this to prevent word splitting. ^--------------------^ SC3001: In POSIX sh, process substitution is undefined. ^------------^ SC3001: In POSIX sh, process substitution is undefined. ^---------------------------^ SC3001: In POSIX sh, process substitution is undefined. ^-------------------^ SC3001: In POSIX sh, process substitution is undefined. ^------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: brew rm $(join <(sort <(brew leaves)) <(sort <(brew deps "$_target"))) In pacapt line 1104: local _dcache ^-----------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 1109: _error "${FUNCNAME[0]}: Unable to delete '$_dcache'." ^------------^ SC3028: In POSIX sh, FUNCNAME is undefined. ^------------^ SC3054: In POSIX sh, array references are undefined. In pacapt line 1122: 2>&1 brew install $_TOPT "$@" \ ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: 2>&1 brew install "$_TOPT" "$@" \ In pacapt line 1124: ret=( ${PIPESTATUS[*]} ) ^------------------^ SC3030: In POSIX sh, arrays are undefined. ^--------------^ SC2206: Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a. ^--------------^ SC3028: In POSIX sh, PIPESTATUS is undefined. ^--------------^ SC3054: In POSIX sh, array references are undefined. In pacapt line 1125: if [[ "${ret[1]}" == 126 ]]; then ^----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. ^-------^ SC3054: In POSIX sh, array references are undefined. In pacapt line 1127: brew cask install $_TOPT "$@" ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: brew cask install "$_TOPT" "$@" In pacapt line 1129: return "${ret[0]}" ^-------^ SC3054: In POSIX sh, array references are undefined. In pacapt line 1156: if [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1197: if [[ "$_TOPT" == "fetch" ]]; then ^-----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1231: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1233: elif [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1241: if [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1282: if [[ "$_TOPT" == "fetch" ]]; then ^-----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1324: if [[ "$_TOPT" == "q" && ! -z "$*" ]]; then ^-- SC3010: In POSIX sh, [[ ]] is undefined. ^-- SC2236: Use -n instead of ! -z. In pacapt line 1326: elif [[ "$_TOPT" == "q" && -z "$*" ]];then ^-- SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1328: elif [[ "$_TOPT" == "" && ! -z "$*" ]]; then ^-- SC3010: In POSIX sh, [[ ]] is undefined. ^-- SC2236: Use -n instead of ! -z. In pacapt line 1330: elif [[ "$_TOPT" == "" && -z "$*" ]];then ^-----------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1338: if [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1346: if [[ "$_TOPT" == "" ]];then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1387: if [[ -z "$*" ]];then ^-----------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1396: if [[ -z "$PKG_CACHE" ]];then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1398: elif [[ ! -d "$PKG_CACHE" ]];then ^---------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1424: if [[ -x '/usr/bin/qlist' ]]; then ^-----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1426: elif [[ -x '/usr/bin/equery' ]]; then ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1434: if [[ -x '/usr/bin/equery' ]]; then ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1450: if [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1451: if [[ -x '/usr/bin/eix' ]]; then ^---------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1453: elif [[ -x '/usr/bin/equery' ]]; then ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1465: if [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1481: if [[ -x '/usr/bin/layman' ]]; then ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1496: if [[ -x "/usr/bin/layman" ]]; then ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1505: if [[ -x "/usr/bin/eix" ]]; then ^---------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1513: if [[ -x "/usr/bin/eclean-dist" ]]; then ^-----------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1521: if [[ -x "/usr/bin/eclean" ]]; then ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1541: if [[ "$(uname)" == "SunOS" ]]; then ^-------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1566: if [[ "$_TOPT" == "q" && ! -z "$*" ]]; then ^-- SC3010: In POSIX sh, [[ ]] is undefined. ^-- SC2236: Use -n instead of ! -z. In pacapt line 1568: elif [[ "$_TOPT" == "q" && -z "$*" ]]; then ^-- SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1632: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1635: elif [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1647: if [[ -z "$*" ]]; then ^-----------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1652: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1678: local _forced="" ^-----------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 1680: if grep -q -- "--forced" <<<"$*"; then ^-^ SC3011: In POSIX sh, here-strings are undefined. In pacapt line 1684: while (( $# )); do ^------^ SC3006: In POSIX sh, standalone ((..)) is undefined. In pacapt line 1685: if [[ "$1" == "--forced" ]]; then ^----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1697: local _auto="" ^---------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 1699: if grep -q -- "--auto" <<<"$*"; then ^-^ SC3011: In POSIX sh, here-strings are undefined. In pacapt line 1703: while (( $# )); do ^------^ SC3006: In POSIX sh, standalone ((..)) is undefined. In pacapt line 1704: if [[ "$1" == "--auto" ]]; then ^--------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1740: local _forced="" ^-----------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 1742: if grep -q -- "--forced" <<<"$*"; then ^-^ SC3011: In POSIX sh, here-strings are undefined. In pacapt line 1746: while (( $# )); do ^------^ SC3006: In POSIX sh, standalone ((..)) is undefined. In pacapt line 1747: if [[ "$1" == "--forced" ]]; then ^----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1811: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1813: elif [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1853: if [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1897: yum install $_TOPT "$@" ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: yum install "$_TOPT" "$@" In pacapt line 1948: if [[ "$_TOPT" == "q" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1952: elif [[ "$_TOPT" == "" ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1960: if [[ "$_TOPT" == "s" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1974: if [[ -f "$file" ]]; then ^--------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1977: done < <(rpm -ql "$@") ^-------------^ SC3001: In POSIX sh, process substitution is undefined. In pacapt line 1984: if [[ "$_TOPT" == "s" ]]; then ^-------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1994: if [[ -f "$file" ]]; then ^--------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 1997: done < <(rpm -ql "$@") ^-------------^ SC3001: In POSIX sh, process substitution is undefined. In pacapt line 2011: if [[ $# -eq 0 ]]; then ^------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2045: local packages= ^------------^ SC3043: In POSIX sh, 'local' is undefined. In pacapt line 2050: | grep -q "$@" && echo $package ^------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: | grep -q "$@" && echo "$package" In pacapt line 2055: zypper install $_TOPT "$@" ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: zypper install "$_TOPT" "$@" In pacapt line 2318: "zypper_Rs") ;; ^---------^ SC2221: This pattern always overrides a later one on line 2321. In pacapt line 2321: "zypper_Rs") ;; ^---------^ SC2222: This pattern never matches because of a previous pattern on line 2318. In pacapt line 2363: if [[ -z "$PACAPT_DEBUG" ]]; then ^----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2364: [[ "$_PACMAN" != "pacman" ]] \ ^--------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2366: elif [[ "$PACAPT_DEBUG" != "auto" ]]; then ^-----------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2383: [[ "${_args:0:1}" == "-" ]] || break ^-------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. ^----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2404: while [[ "$i" -lt "${#_args}" ]]; do ^------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2405: _opt="${_args:$i:1}" ^-----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2406: (( i ++ )) ^--------^ SC3006: In POSIX sh, standalone ((..)) is undefined. ^-- SC3018: In POSIX sh, ++ is undefined. In pacapt line 2423: if [[ -n "$_POPT" && "$_POPT" != "$_opt" ]]; then ^-- SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2445: if [[ "$_SOPT" == '' ]]; then ^------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2470: if [[ "${_SOPT:0:1}" < "$_opt" ]]; then ^----------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. ^----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2471: _SOPT="${_SOPT:0:1}$_opt" ^----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2472: elif [[ "${_SOPT:0:1}" == "$_opt" ]]; then ^-----------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. ^----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2475: _SOPT="$_opt${_SOPT:0:1}" ^----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2484: if [[ "${_SOPT:0:1}" == "y" ]]; then ^-------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. ^----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2492: if [[ "${_SOPT:0:1}" == "u" ]]; then ^-------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. ^----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2500: if [[ "${_SOPT:0:2}" == "cc" ]]; then ^--------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. ^----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2502: elif [[ "${_SOPT:0:1}" == "c" ]]; then ^-------------------------^ SC3010: In POSIX sh, [[ ]] is undefined. ^----------^ SC3057: In POSIX sh, string indexing is undefined. In pacapt line 2527: if [[ -n "$_POPT" && -n "$_SOPT" ]]; then ^-- SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2536: elif [[ -z "${_POPT}${_SOPT}${_TOPT}" ]]; then ^-- SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2541: [[ -n "$_POPT" ]] \ ^---------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2552: if [[ -n "$*" ]]; then ^-----------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2564: if [[ -n "$PACAPT_DEBUG" ]]; then ^----------------------^ SC3010: In POSIX sh, [[ ]] is undefined. In pacapt line 2567: declare -f "${_PACMAN}_${_POPT}${_SOPT}" ^-- SC3044: In POSIX sh, 'declare' is undefined. In pacapt line 2570: "${_PACMAN}_${_POPT}${_SOPT}" $_EOPT "$@" ^----^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: "${_PACMAN}_${_POPT}${_SOPT}" "$_EOPT" "$@" For more information: https://www.shellcheck.net/wiki/SC1087 -- Use braces when expanding arrays,... https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ... https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. ... ```

icy commented 3 years ago

We don't really need to rewrite all parts using POSIX. We just need POSIX on some restricted environment . e.g OpenWRT (https://github.com/icy/pacapt/issues/62). Is that possible to switch the shell at the run-time, @cuonglm ?

cuonglm commented 3 years ago

@icy what do you mean "switch the shell at run-time"?

You can call exec to replace the current process (bash) with the new process (sh), but you still need bash anyway.

icy commented 3 years ago

Oh, exec is a nice idea. What I would need is to launch bash from sh (not vice-versa). Let's say when user is within openwrt where sh is available (hopefully:D), if we can't see bash there, we continue until it's exhausted; otherwise, we switch over to bash. This is only applicable when the library strictly requires a POSIX shell.

rami3l commented 3 years ago

shellcheck POSIX logs (pacapt-2.4.4)

...

@icy Can you use foldable code blocks? That looks like a spam to me otherwise :/

icy commented 3 years ago

shellcheck POSIX logs (pacapt-2.4.4) ...

@icy Can you use foldable code blocks? That looks like a spam to me otherwise :/

Sorry I thought that's done automatically :dagger:

icy commented 3 years ago

With recent changes in https://github.com/icy/pacapt/pull/161/files:

icy commented 3 years ago

Great Saturday. I finally can mix up both POSIX and non-POSIX features in the same script. The script detects and loads non-POSIX features dynamically (this was what I couldn't do in any elegant way in my Dlang code :D). Feel free to give a CR on https://github.com/icy/pacapt/pull/161/files . Thanks a lot.

cc: @cuonglm @LaszloGombos @NgoHuy