mirror of
https://github.com/openwrt/packages.git
synced 2026-01-09 19:31:21 +00:00
ddns-scripts: fixes "sed: no previous regexp"
Rewritten Pull for #5885 When ran from the command line, the script prints error messages like below. They are caused by supplying empty "$password" and "$URL_PASS" for some log messages like "130822 : Detect local IP on 'interface'". The fix is to check if the values are not empty before running through sed. /etc/init.d/ddns start sed: no previous regexp Reported by Marc Benoit <marcb62185@gmail.com> Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
This commit is contained in:
@@ -262,9 +262,9 @@ write_log() {
|
||||
[ $VERBOSE -gt 0 -o $__EXIT -gt 0 ] && echo -e "$__MSG"
|
||||
# write to logfile
|
||||
if [ ${use_logfile:-1} -eq 1 -o $VERBOSE -gt 1 ]; then
|
||||
printf "%s\n" "$__MSG" | \
|
||||
sed -e "s/$password/*password*/g; \
|
||||
s/$URL_PASS/*URL_PASS*/g" >> $LOGFILE
|
||||
[ -n "$password" ] && __MSG=$( printf "%s" "$__MSG" | sed -e "s/$password/*password*/g" )
|
||||
[ -n "$URL_PASS" ] && __MSG=$( printf "%s" "$__MSG" | sed -e "s/$URL_PASS/*URL_PASS*/g" )
|
||||
printf "%s\n" "$__MSG" >> $LOGFILE
|
||||
# VERBOSE > 1 then NO loop so NO truncate log to $ddns_loglines lines
|
||||
[ $VERBOSE -gt 1 ] || sed -i -e :a -e '$q;N;'$ddns_loglines',$D;ba' $LOGFILE
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user