Search code examples
bashshellcommandshunzip

"Archive:: command not found" while trying to use unzip command inside of shell function


I have a very short script called "./wget_unzip.sh" :

#!/bin/sh
function wget_unzip {
    wget $1
    unzip ./patch\?zip
}

$(wget_unzip "https://www.mylinktoagerritpatch.org/patch?zip")

It should wget a tiny (~1KB) archive called "patch?zip" and then unzip it (inside there's a .diff file for a patch). This line

unzip ./patch\?zip
  • is working fine while at the main body of script; however, if moved to inside of a function like above, it starts failing with

    ./wget_unzip.sh: line 7: Archive:: command not found
    

If I'd try to replace unzip with /usr/bin/unzip, I'll get another error:

./wget_unzip.sh: line 7: UnZip:: command not found

Everything is fine with another command - wget - so I wonder what's wrong with unzip...


Solution

  • there is nothing wrong with unzip, just how you called the function
    remove the $()