0

I'm new to vim and bash and something seems odd to me. I have two functions and they have a different highlighting, but I can't understand why. I searched through google, but I haven't found an answer to this specific problem.

Here's how the code looks like with syntax highlighting:

Functions

function unlock() {
    rm -f ${LOCKFILE}
    if [ -f ${LOCKFILE} ]; then
        echo "ERROR: Unable to delete lockfile ${LOCKFILE}!"
        exit 1
    fi
    echo_debug "lock file ${LOCKFILE} removed."
}

function copy_file() {
        #  scp -q -i "$RSA_FILE" -P "$NEXTCLOUD_SERVER_PORT" "$1" \
        #     "$NEXTCLOUD_SERVER_USER@$NEXTCLOUD_SERVER_HOST:$NEXTCLOUD_SERVER_DEST_DIR"
        echo "copy_file()"
}

I noticed that if I add another function named coFUNCTION() the highlighting changes to the one like copy_file(). Why is this the case?

Here's my .vimrc

1 set number
2 syntax on
3 :color desert
Ri1a
  • 737
  • 9
  • 26

1 Answers1

3

sh != bash, and the function keyword is a bashism. So it's entirely possible the syntax highlighting is correct, except it's been applied to the wrong language. You can simply remove the function keyword to get closer to POSIX syntax, that might help the highlighting code. Or, depending on how the highlighting code works you might have more luck adding a shebang line or changing the script extension from "sh" to "bash".

l0b0
  • 55,365
  • 30
  • 138
  • 223