arfoll / unrarall

bash script to unrar everything and cleanup in a given directory
GNU General Public License v3.0
260 stars 68 forks source link

unrarall: line 110: `clean-up': not a valid identifier #26

Closed josephbisaillon closed 7 years ago

josephbisaillon commented 9 years ago

getting an

unrarall: line 110: `clean-up': not a valid identifier

arfoll commented 9 years ago

we'll need more details - how about platform/OS/shell? and how you are running it?

josephbisaillon commented 9 years ago

I am running a variant of archlinux off of a USB stick on a Zyxel NSA320 nas box. It's running bash 4 and I changed the top of the script to the directory location of my bash which is /ffp/bin/bash

josephbisaillon commented 9 years ago

I believe version 2.6.31.8

arfoll commented 9 years ago

And have you made sure to change which shell this is being executed under in the shebang instead of - I'm guessing - busybox? Also what's the exact command you're running?

arfoll commented 9 years ago

this looks like a typical issue with a reduced shell like busybox sh

josephbisaillon commented 9 years ago

Ah I'm not too familiar with linux, what should I be checking? It does seem that I have busybox on the machine though. I just checked that.

arfoll commented 9 years ago

change the first line of the script https://github.com/arfoll/unrarall/blob/master/unrarall#L1 to be #!/ffp/bin/bash

josephbisaillon commented 9 years ago

ah yes I did that. and still ran into the same issue.

arfoll commented 9 years ago

How are you executing unrarall? The full command line with all parameters

arfoll commented 9 years ago

Actually interestingly bash may not technically support function names with a hyphen @delcypher you ever heard of that? (http://stackoverflow.com/questions/28114999/what-are-the-rules-for-valid-identifiers-e-g-functions-vars-etc-in-bash)

@josephbisaillon try maybe renaming clean-up to cleanup and see if that works for you

josephbisaillon commented 9 years ago

I did that earlier and it ran a little more then broke at the next function with a dash. BUT you did just make me think making running it with /ffp/bin/bash unrarall --verbose --dry would work..AND it looks like it's working! I'm not sure if that would be the proper line to run. I am trying to extract files, if they are already extracted bypass and delete original rars. if not extract and THEn delete original rars.

arfoll commented 9 years ago

--dry will do nothing, we extract even if stuff is 'already extracted' because checking and making sure is rather difficult. What bash version are you using? It's weird because my nas runs arch linux and I've not seen the issue :/

josephbisaillon commented 9 years ago

Bash 4.1.11(2) -release

But I wouldn't put it past my system being a little funky. I've done a lot of horrible things to this poor nas box because it was my first real linux experience haha. Thanks for all the help though it seems to be working!

delcypher commented 9 years ago

Actually interestingly bash may not technically support function names with a hyphen @delcypher you ever heard of that? (http://stackoverflow.com/questions/28114999/what-are-the-rules-for-valid-identifiers-e-g-functions-vars-etc-in-bash)

No but the docs probably aren't lying. Using - as a separator was a bad idea on my part. We should replace them with _ instead.

josephbisaillon commented 9 years ago

Don't know if this will help or if you want to try to implement something like this. But this is the script that I use to extract all rar recursively in a directory. It works pretty well and ignores files that have already been extracted.

josephbisaillon commented 9 years ago
# WHAT THIS DOES:
# The below script will extract each rar file into its current directory (the rars will make whatever subdirectories they need to make - which ever ones they contain of course).
# WHAT TO DO:
# 1. fill out SOURCE variable (thats where all of the rars are, well they dont necesarry have to be on the same folder level, they could be a few folders deep, but this will be the root of the operation)
# 2. pick whichever OVERWRITE option you want
# 3. copy paste the script into the shell (the parenthesis on the outsides of the script make sure it all runs nicely together)
# MORE INFO ON OVERWRITE VARIABLE:
# the overwrite variable, pick either -o+ for overwrite, -o- for not overwrite, or empty " " for prompts on overwrite. Make sure to hash out the ones you dont want. I like overwrite because then I ensure a good clean copy.
(SOURCE='/i-data/video/Downloads/DLtoNAS'
# OVERWRITE="-o+"
OVERWRITE="-o-" 
cd $SOURCE
OLDIFS=$IFS
IFS=$'\n'
for i in `find -type f | grep rar$`; do 
echo "### --------[`date +%D-%T`][`date +%s`]--------";
FILEFULLPATH=`readlink -f $i`;
FULLDIR=`dirname $FILEFULLPATH`;
echo "### EXTRACTING ${i} TO ${FULLDIR}:"
echo "### unrar x $OVERWRITE ${i} ${FULLDIR}"
unrar x $OVERWRITE "${i}" "${FULLDIR}";
done;
IFS=$OLDIFS)