I am attempting to write a simple pipe menu generator for Openbox, which lists files and directories, and lets you open a shell in a listed directory if you want. It's written in bash, and looks like this:
File Edit Options Buffers Tools Sh-Script Help #!/bin/sh # dirpipe.sh: generates an Openbox pipe menu of directories terminal="uxterm" user_shell="/bin/bash" self="$0" current_dir="$1" if [ ! $current_dir ]; then current_dir="$HOME" echo "<openbox_pipe_menu>" cat <<END <item label="Shell here..."><action name="execute"><execute>$terminal -e "cd $c\ urrent_dir && $user_shell"</execute></action></item> <separator/> END for $i in `ls $current_dir`; do if [ -d $i ]; then cat <<END <item label="$i execute="$self $i"/> END else cat <<END <item label="$i"/> END fi done echo "</openbox_pipe_menu>"
The above is verbatim. There are no indentation issues, no Windows-style carriage returns, and no missing "fi" statements. Yet on running it, I get this:
./dirpipe.sh: line 28: syntax error: unexpected end of file
I have been trying to coax a more useful error message out of bash, and so far I have failed. I still have no idea where I screwed up. What am I doing wrong here?
Last edited by Gullible Jones (2012-12-24 00:14:44)
Gah! Thank you very much.
Edit: also found several other bugs, which are now fixed. Will post final version in the Contributions section.
Edit 2: or not! I'm sorry, the above is extremely bug ridden. I will do my best to correct the issues I see...
Last edited by Gullible Jones (2012-12-24 01:19:13)
And come the morning, all the problems become obvious...
I'll post this in Community Contributions now that it works correctly. Again, thank you!