#!/bin/sh
-. /usr/share/os-prober/common.sh
+. usr/share/os-prober/common.sh
set -e
partition="$1"
menuentry)
entry_result
shift 1
- # The double-quoted string is the title.
- # Make sure to look at the text of the line
- # before 'set' mangled it.
- title="$(echo "$line" | sed -n 's/[^"]*"\(.*\)".*/\1/p' | sed 's/://g')"
- if [ -z "$title" ]; then
- # ... or single-quoted? Be careful
- # to handle constructions like
- # 'foo'\''bar' (which expands to
- # foo'bar, as in shell), and to
- # handle multiple single-quoted
- # strings on the same line.
- title="$(echo "$line" | sed -n "s/[^']*'\(\([^']\|'\\\\''\)*\)'.*/\1/p" | sed "s/'\\\\''/'/; s/://g")"
- fi
+ # strip all of: --option=abcd --option='ab cd' --option="ab cd" menuentry { command block
+ # and everything else except the first quoted string or non-space word
+ # and remove any : from the remaining title
+ title=$( printf "%s" "$line" | sed -n "s/^[[:blank:]]*//; p" )
+ title=$( printf "%s" "$title" | sed -n "s/--[^ ]*=\(\([\"']\)[^\"']*\2 \|[^ ]* \)//g; p" )
+ title=$( printf "%s" "$title" | sed -n "s/{//; p" )
+ title=$( printf "%s" "$title" | sed -n "s/menuentry//; p" )
+ title=$( printf "%s" "$title" | sed -n "s/^[ ]*\(\([\"']\{1\}\)\(.*\)\2\|\([^\"' ][^ ]*\)\).*/\3\4/; p" )
+ title=$( printf "%s" "$title" | sed -n "s/\\\\'//; p" )
+ title=$( printf "%s" "$title" | sed -n "s/''//; p" )
+ title=$( printf "%s" "$title" | sed -n "s/://g; p" )
if [ -z "$title" ]; then
+ echo "No title: $line"
ignore_item=1
elif echo "$title" | grep -q '(on /dev/[^)]*)$'; then
log "Skipping entry '$title':"