Variable passed to system contains garbage characters
Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables uname output: Linux DL.second 2.6.23.1 #1 Sun Oct 21 17:49:04 CEST 2007 i686 athlon i386 GNU/Linux Machine Type: i686-redhat-linux-gnu Bash Version: 3.2 Patch Level: 33 Release Status: release Description: The script below fails on my box with the following output: 1197676800 date: invalid date `1970-01-01 \033[?1034h1197676800 sec' So for some reason the value passed to date got a nasty prefix. I guess this could be charset-related, so here's my locale LANG=en_US LC_CTYPE="en_US" LC_NUMERIC="en_US" LC_TIME="en_US" LC_COLLATE="en_US" LC_MONETARY="en_US" LC_MESSAGES="en_US" LC_PAPER="en_US" LC_NAME="en_US" LC_ADDRESS="en_US" LC_TELEPHONE="en_US" LC_MEASUREMENT="en_US" LC_IDENTIFICATION="en_US" LC_ALL= Repeat-By: executing this script #!/bin/bash let "STEP=86400" let "CALCTIME=`date +%s`" export DAYSTART=`echo "$CALCTIME - ($CALCTIME % $STEP) - $STEP" |bc -i |tail -1` echo "$DAYSTART" export BASHBUG=`date -d "1970-01-01 $DAYSTART sec" +"%Y-%m-%d %T"` Fix: Yes, please ;)
Re: Variable passed to system contains garbage characters
At 17.12.2007, Chet Ramey wrote: I can't reproduce this on fedora core 6, which is the closest Linux box. I suspect this is prompt string or PROMPT_COMMAND related, so a transcript of running this script with `bash -x' would help. No problem: $ bash -x "./test.sh" + alias 'scr=screen -R ' + '[' -f /etc/bashrc ']' + . /etc/bashrc ++ '[' 508 -gt 99 ']' +++ id -gn +++ id -un ++ '[' donkey = donkey ']' ++ umask 002 ++ '[' '' ']' ++ shopt -q login_shell ++ for i in '/etc/profile.d/*.sh' ++ '[' -r /etc/profile.d/colorls.sh ']' ++ . /etc/profile.d/colorls.sh +++ alias 'll=ls -l' +++ alias 'l.=ls -d .*' +++ COLORS=/etc/DIR_COLORS +++ '[' -e /etc/DIR_COLORS.xterm ']' +++ COLORS=/etc/DIR_COLORS.xterm +++ '[' -e /home/donkey/.dircolors ']' +++ '[' -e /home/donkey/.dircolors.xterm ']' +++ '[' -e /home/donkey/.dir_colors ']' +++ '[' -e /home/donkey/.dir_colors.xterm ']' +++ '[' -e /etc/DIR_COLORS.xterm ']' dircolors --sh /etc/DIR_COLORS.xterm +++ eval 'LS_COLORS='\''no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:'\'';' export LS_COLORS LS_COLORS='no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:' export LS_COLORS +++ '[' -z 'no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:' ']' +++ egrep -qi '^COLOR.*none' /etc/DIR_COLORS.xterm +++ alias 'll=ls -l --color=tty' +++ alias 'l.=ls -d .* --color=tty' +++ alias 'ls=ls --color=tty' ++ for i in '/etc/profile.d/*.sh' ++ '[' -r /etc/profile.d/cvs.sh ']' ++ . /etc/profile.d/cvs.sh +++ export CVS_RSH=ssh +++ CVS_RSH=ssh ++ for i in '/etc/profile.d/*.sh' ++ '[' -r /etc/profile.d/glib2.sh ']' ++ . /etc/profile.d/glib2.sh +++ export G_BROKEN_FILENAMES=1 +++ G_BROKEN_FILENAMES=1 ++ for i in '/etc/profile.d/*.sh' ++ '[' -r /etc/profile.d/krb5-devel.sh ']' ++ . /etc/profile.d/krb5-devel.sh +++ echo /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/donkey/bin +++ /bin/grep -q /usr/kerberos/bin +++ echo /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/donkey/bin +++ /bin/grep -q /usr/kerberos/sbin /usr/bin/id -u +++ '[' 508 = 0 ']' ++ for i in '/etc/profile.d/*.sh' ++ '[' -r /etc/profile.d/lang.sh ']' ++ . /etc/profile.d/lang.sh +++ sourced=0 +++ '[' -n en_US ']' +++ sourced=1 +++ '[' -n '' ']' +++ '[' 1 = 1 ']' +++ '[' -n en_US ']' +++ export LANG +++ '[' -n '' ']' +++ unset LC_ADDRESS +++ '[' -n '' ']' +++ unset LC_CTYPE +++ '[' -n '' ']' +++ unset LC_COLLATE +++ '[' -n '' ']' +++ unset LC_IDENTIFICATION +++ '[' -n '' ']' +++ unset LC_MEASUREMENT +++ '[' -n '' ']' +++ unset LC_MESSAGES +++ '[' -n '' ']' +++ unset LC_MONETARY +++ '[' -n '' ']' +++ unset LC_NAME +++ '[' -n '' ']' +++ unset LC_NUMERIC +++ '[' -n '' ']' +++ unset LC_PAPER +++ '[' -n '' ']' +++ unset LC_TELEPHONE +++ '[' -n '' ']' +++ unset LC_TIME +++ '[' -n '' ']' +++ unset LC_ALL +++ '[' -n '' ']' +++ unset LANGUAGE +++ '[' -n '' ']' +++ unset LINGUAS +++ '[' -n '' ']' +++ unset _XKB_CHARSET /sbin/consoletype +++ consoletype=pty +++ '[' -n '' ']' +++ '[' -n '' ']' +++ '[' -n en_US ']' +++ case $LANG in +++ '[' xterm = linux ']' +++ unset SYSFONTACM SYSFONT +++ unset sourced +++ unset langfile ++ for i in '/etc/profile.d/*.sh' ++ '[' -r /etc/profile.d/less.sh ']' ++ . /etc/profile.d/less.sh +++ '[' -x /usr/bin/lesspipe.sh ']' +++ export 'LESSOPEN=|/usr/bin/lesspipe.sh %s' +++ LESSOPEN='|/usr/bin/lesspipe.sh %s' ++ for i in '/etc/profile.d/*.sh' ++ '[' -r /etc/profile.d/mc.sh ']' ++ . /etc/profile.d/mc.sh +++ alias 'mc=. /usr/share/mc/bin/mc-wrapper.sh' ++ for i in '/etc/profile.d/*.sh' ++ '[' -r /etc/profile.d/vim.sh ']' ++ . /etc/profile.d/vim.sh +++ '[' -n '3.2.33(1)-release' -o -n '' -o -n '' ']' +++ '[' -x //usr/bin/id ']' //usr/bin/id -u +++ '[' 508 -le 100 ']' +++ alias vi +++ alias vi=vim ++ for i in '/etc/profile.d/*.sh' ++ '[' -r /etc/profile.d/which-2.sh ']' ++ . /etc/profile.d/which-2.sh +++ alias 'which=alias
Re: Variable passed to system contains garbage characters
At 17.12.2007, Bob Proulx wrote: Patrick Nagelschmidt wrote: > The script below fails on my box with the following output: > > 1197676800 > date: invalid date `1970-01-01 \033[?1034h1197676800 sec' > > So for some reason the value passed to date got a nasty prefix. I cannot recreate the problem. However I think your issue is because you are forcing bc into interactive mode. Ok, thanks guys, you are both right, the interactive mode was the cause for this. how could i ever doubt the purity of the bash :) Br, Patrick