Giter VIP home page Giter VIP logo

Comments (9)

niieani avatar niieani commented on May 22, 2024

Hm, seems your version of bash doesn't have global variables (-g). If
possible, try bash>=4.2.
I'll try to figure out a workaround.
On Mon, 15 Feb 2016 at 09:50, Łukasz Schabek [email protected]
wrote:

Have this error when running your-script.sh on Solaris.

$ uname -a
SunOS deuxviqm 5.11 11.2 sun4v sparc sun4v
$ bash --version
GNU bash, version 4.1.17(1)-release (sparc-sun-solaris2.11)
$ ./your-script.sh
/pkg/vdcro/tools/bash-oo/lib/oo-bootstrap.sh: line 44: declare: -g:
invalid option
declare: usage: declare [-aAfFilrtux] [-p] [name[=value] ...]
/pkg/vdcro/tools/bash-oo/lib/oo-bootstrap.sh: line 45: declare: -g:
invalid option
declare: usage: declare [-aAfFilrtux] [-p] [name[=value] ...]
/pkg/vdcro/tools/bash-oo/lib/oo-bootstrap.sh: line 176: declare: -g:
invalid option
declare: usage: declare [-aAfFilrtux] [-p] [name[=value] ...]
/pkg/vdcro/tools/bash-oo/lib/oo-bootstrap.sh: line 177: declare: -g:
invalid option
declare: usage: declare [-aAfFilrtux] [-p] [name[=value] ...]
/pkg/vdcro/tools/bash-oo/lib/oo-bootstrap.sh: line 178: declare: -g:
invalid option
declare: usage: declare [-aAfFilrtux] [-p] [name[=value] ...]
/pkg/vdcro/tools/bash-oo/lib/oo-bootstrap.sh: line 190: declare: -g:
invalid option
declare: usage: declare [-aAfFilrtux] [-p] [name[=value] ...]


Reply to this email directly or view it on GitHub
#16.

from bash-oo-framework.

JaredTS486 avatar JaredTS486 commented on May 22, 2024

Declare -x is the other method for global variables.
I used the following on SunOS ${BASH_VERSION}=3.2.57(1)-release
[[ "${BASH_VERSION:0:1}" -lt 4 ]] && P="x" || P="g"
...
...
declare -${P} __oo__libPath="$( cd "${BASH_SOURCE[0]%/*}" && pwd )"
declare -${P} __oo__path="${__oo__libPath}/.."
declare -${P}a __oo__importedFiles

from bash-oo-framework.

niieani avatar niieani commented on May 22, 2024

-x exports the variables, that's not the same as making them global. The thing is, you can't export arrays or associative arrays, which is what the framework currently depends on. How much of the framework seemed to work under bash 3.2.57, @JaredTS486? I would imagine many parts to be broken without a proper porting process.

from bash-oo-framework.

JaredTS486 avatar JaredTS486 commented on May 22, 2024

That is true they are not the same but for bash 3.2 that is the only alternative and so far does the trick. I got most of the framework sourced without any errors after I changed the declares and modified the Aliases but made no direct function calls. Most recently I was working on log.sh attempting to use eval and indirect variable references to mimic the associative arrays. I manage scripts that run on both 3.2 and 4.2 so I know some methods for portability.

from bash-oo-framework.

niieani avatar niieani commented on May 22, 2024

Ah, cool. Did you manage to get console logging running?

from bash-oo-framework.

JaredTS486 avatar JaredTS486 commented on May 22, 2024

I did but it required changing some major parts to Color.sh

declare/export only allow characters A-Z, a-z, 0-9, and _
So UI.Color.Default became UI_Color_Default etc...

Also had to change UI_Color_IsAvailable to a function that performs the same check.
UI_Color_IsAvailable(){ if $([ $(tput colors 2>/dev/null || echo 0) -ge 16 ] && [ -t 1 ]) ; then return 0 ; else return 1 ; fi }

Also:
UI_Powerline_IsAvailable(){ if UI_Color_IsAvailable && test -z $NO_UNICODE && (echo -e $'\u1F3B7' | grep -v F3B7) &> /dev/null ; then return 0 ; else return 1 ; fi }

Then the call below seemed to work without errors.
Console::WriteStdErr "This will be printed to STDERR, no matter what."

from bash-oo-framework.

niieani avatar niieani commented on May 22, 2024

Cool, thanks for investigating!

from bash-oo-framework.

Tzrlk avatar Tzrlk commented on May 22, 2024

Will this get integrated into the next release?

from bash-oo-framework.

niieani avatar niieani commented on May 22, 2024

@Tzrlk I think a version supporting bash 3 would have to differ by quite a bit of modules, but I'd be up for supporting bash 4.0 in master if you wanna PR that. PR's welcome for both, we can keep the backwards compatible version in a bash-3 branch.

from bash-oo-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.