Find the answer to your Linux question:
Results 1 to 4 of 4
I am writing my my first shell script which as it happens is a pre-commit hook for subversion. The intent is to give a message if no log entry is ...
  1. #1
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298

    Unexpected end of file

    I am writing my my first shell script which as it happens is a pre-commit hook
    for subversion. The intent is to give a message if no log entry is found when
    committing.

    When I attempt a commit (either with or without a log entry) I get an error that
    says line 17: syntax error: Unexpected end of file

    Any clues as to what I am doing wrong?

    Code:
    #!/bin/sh
    
    # PRE-COMMIT HOOK
    REPOS="$1"
    TXN="$2"
    
    # Make sure that the log message contains some text.
    SVNLOOK=/usr/bin/svnlook
    $SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]{4,}" > /dev/null
    if %errorlevel%=0 exit 0
    
    echo "Your commit has been disallowed as you have provided no log entry"
    echo "Please try again with a log message including the sales order or support number"
    echo "This means YOU!"
    
    exit 1
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  2. #2
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    845
    You have a problem with your if statement. Try:

    Code:
    if %errorlevel%=0 ; then exit 0 ; fi
    Linux User #453176

  3. #3
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    The if looks like a DOSism. Details on bash decisions can be found in http://www.tldp.org/LDP/Bash-Beginne...l/chap_07.html for example ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  4. #4
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    Thanks guys. You pointed me in the right direction

    The code that finally worked (who'd a thunk the spaces in the []
    would be so damned important!)

    Code:
    #!/bin/sh
    
    # PRE-COMMIT HOOK
    REPOS="$1"
    TXN="$2"
    
    # Make sure that the log message contains some text.
    /usr/bin/svnlook log -t "$TXN" "$REPOS" | /bin/grep "[a-zA-Z0-9]" > /dev/null
    if [ $? = 0 ]
            then exit 0;
    fi
    
    echo "Your commit has been disallowed as you have provided no log message." 1>&2
    echo "Please try again with a log message including the sales order or support number." 1>&2
    echo "This means YOU!" 1>&2
    
    exit 1
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...