You are not logged in.

#1 2012-12-24 00:14:25

Gullible Jones
Member
Registered: 2004-12-29
Posts: 4,863

bash: "unexpected end of file" how?

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)

Offline

#2 2012-12-24 00:26:08

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,791
Website

Re: bash: "unexpected end of file" how?

Gullible Jones wrote:

...and no missing "fi" statements

if [ ! $current_dir ]; then current_dir="$HOME"

I don't see a fi for this...


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#3 2012-12-24 01:04:37

Gullible Jones
Member
Registered: 2004-12-29
Posts: 4,863

Re: bash: "unexpected end of file" how?

Gah! Thank you very much. sad

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)

Offline

#4 2012-12-24 15:22:58

Gullible Jones
Member
Registered: 2004-12-29
Posts: 4,863

Re: bash: "unexpected end of file" how?

And come the morning, all the problems become obvious...

I'll post this in Community Contributions now that it works correctly. Again, thank you!

Offline

Board footer

Powered by FluxBB