internetwache/GitTools

Error gitdumper.sh: line 25: declare: -n: invalid option

voldedore opened this issue · 3 comments

I am experiencing this issue while running bash gitdumper.sh (no param)

It worked well on my other Fedora machine but on my macOS at work, it throws that error.

More details:
macOS 10.12
sh used: zsh (changed to bash but the same occurred)

Full error information:

╰─ bash gitdumper.sh
###########
# GitDumper is part of https://github.com/internetwache/GitTools
#
# Developed and maintained by @gehaxelt from @internetwache
#
# Use at your own risk. Usage might be illegal in certain circumstances.
# Only for educational purposes!
###########


gitdumper.sh: line 25: declare: -n: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
\e[33m[*] USAGE: http://target.tld/.git/ dest-dir [--git-dir=otherdir]\e[0m
		--git-dir=otherdir		Change the git folder name. Default: .git

Hi,

that's because zsh does not have "declare". Afaik this is a bash feature [0].

You should try: $> bash gitdumper.sh

[0] https://stackoverflow.com/questions/10194861/bash-zsh-declare-oh-my

EDIT: Sorry, didn't carefully read the issue (I'm on vacation... :)). I'm not sure, why the bash gitdumper.sh does not work? Can you try to switch to a bash first and then running the script from there?

$zsh> bash
$bash> gitdumper.sh

Hi,
Thanks for your quick reply. As mentioned from my first post, I switched to bash first then bash gitdumper.sh (even ./gitdumper.sh) but the same error keeps occuring. My PC (with fedora) is running with the same Zsh settings as my mac at work but everything worked perfectly.

Will try again next Monday by your advice. I meant I will try with the command which is only gitdumper.sh

Edited:
Hope this will help you to figure out about this issue. I tested on:

  • Fedora 26 (zsh)
    (zsh) bash gitdumper.sh --> ok
    (zsh) ./gitdumper.sh --> ok
    (zsh) bash --> change to bash
    (bash) ./gitdumper.sh --> ok
    (bash) bash gitdumper.sh --> ok

  • macOS 10.12 (zsh)
    (zsh) bash gitdumper.sh --> NG
    (zsh) bash --> change to bash
    (bash) bash gitdumper.sh --> NG
    (bash) ./gitdumper.sh --> NG

I chmodded u+x the shell file and do the command with the same user.

Hi, I finally get it resolved.

The old version of Apple's built-in bash is the cause of all this.

╰─ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.

After installing new bash from homebrew, everything seems to properly work now.

brew install bash
╰─ /usr/local/bin/bash --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
╰─ /usr/local/bin/bash gitdumper.sh
###########
# GitDumper is part of https://github.com/internetwache/GitTools
#
# Developed and maintained by @gehaxelt from @internetwache
#
# Use at your own risk. Usage might be illegal in certain circumstances.
# Only for educational purposes!
###########


[*] USAGE: http://target.tld/.git/ dest-dir [--git-dir=otherdir]
		--git-dir=otherdir		Change the git folder name. Default: .git