bash: remove the format string "%q" in the unicode3.sub
Hi all When I run the tests for the bash, the sub-test unicode3.sub of intl.tests failed. The sub-test unicode3.sub contain the following: payload=$'\065\247\100\063\231\053\306\123\070\237\242\352\263' "$payload" printf %q "$payload" In this situation, the format string "%q" in command printf means that when the character in the payload is not in {alpha & digit & punctuation & ISO 646(7-bit)}, it would print the string with ANSI-C style quoted string: $'...' , we can check the source code at: http://git.savannah.gnu.org/cgit/bash.git/tree/builtins/printf.def#n557 http://git.savannah.gnu.org/cgit/bash.git/tree/lib/sh/strtrans.c#n207 Because the payload variable contain the above situation, so the test results look like $'...' , when compared with the intl.right that contain the converted character(extended ASCII), so the test failed. Can we remove the format string "%q", so just printf "$payload" In this way, the output of test is same as the intl.right. //dengke
Re: bash: remove the format string "%q" in the unicode3.sub
Hi chet Thanks for you help. 1. This file: http://git.savannah.gnu.org/cgit/bash.git/tree/tests/unicode3.sub?h=devel&id=74b8cbb41398b4453d8ba04d0cdd1b25f9dcb9e3 When executed to the 3 line: "$payload" On my target the output was: unicode3.sub: line 3: 5�@3�+�S8: command not found not the ANSI-C style quoted string like: $'...' in the changed compared file intl.right, the same for the 5 line. http://git.savannah.gnu.org/cgit/bash.git/diff/tests/intl.right?h=devel&id=74b8cbb41398b4453d8ba04d0cdd1b25f9dcb9e3 2. The fixed for printf %q "$payload" in intl.right is fine for me. //dengke On 2016年08月09日 22:39, Chet Ramey wrote: On 8/9/16 3:18 AM, dengke...@windriver.com wrote: Hi all When I run the tests for the bash, the sub-test unicode3.sub of intl.tests failed. The sub-test unicode3.sub contain the following: payload=$'\065\247\100\063\231\053\306\123\070\237\242\352\263' "$payload" printf %q "$payload" In this situation, the format string "%q" in command printf means that when the character in the payload is not in {alpha & digit & punctuation & ISO 646(7-bit)}, it would print the string with ANSI-C style quoted string: $'...' , we can check the source code This has already been changed in the devel branch (back in May, 2015), and the test case and tets output was changed at the same time.
bash test: lastpipe.tests failed
Hi all When I run the bash test lastpipe.tests, there were some errors occurred. The code in lastpipe.tests: shopt -s lastpipe ... exit 142 | false echo $? -- ${PIPESTATUS[@]} The error output: lastpipe.tests: line 41: 708 Exit 142exit 142 703 Hangup | false 129 -- 142 129 The lastpipe.right is: ... 1 -- 142 1 ... When I run the above line by line, it was correct. $ shopt -s lastpipe $ exit 142 | false $ echo $? -- ${PIPESTATUS[@]} $ 1 -- 142 1 That is strange. //dengke
Re: bash: remove the format string "%q" in the unicode3.sub
1. My target was x86-64, using the master 4.3.30 version of bash (Sorry for lacking the information) 2. I used the master version of bash on the unicode3.sub before I will test it for the devel version of bash as soon as. //dengke On 2016年08月10日 19:10, Chet Ramey wrote: On 8/10/16 2:42 AM, dengke...@windriver.com wrote: Hi chet Thanks for you help. 1. This file: http://git.savannah.gnu.org/cgit/bash.git/tree/tests/unicode3.sub?h=devel&id=74b8cbb41398b4453d8ba04d0cdd1b25f9dcb9e3 When executed to the 3 line: "$payload" On my target the output was: unicode3.sub: line 3: 5�@3�+�S8: command not found You don't give any information about your target, but using the devel version of bash on that file produces output using $'...' quoting on all the systems I have tested, since the string contains an invalid multibyte sequence.
Re: bash test: lastpipe.tests failed
But when I run the test line by line, it's OK. I used the version of bash is 4.3.30 on master branch, run the test on the qemux86-64. On 2016年08月10日 19:16, Chet Ramey wrote: On 8/10/16 3:32 AM, dengke...@windriver.com wrote: Hi all When I run the bash test lastpipe.tests, there were some errors occurred. The code in lastpipe.tests: shopt -s lastpipe ... exit 142 | false echo $? -- ${PIPESTATUS[@]} The error output: lastpipe.tests: line 41: 708 Exit 142exit 142 703 Hangup | false 129 -- 142 129 I can't reproduce this. It looks system-specific; there shouldn't be anything sending a SIGHUP to a simple command there.
Re: bash test: lastpipe.tests failed
I used the strace tool to follow it. I touch a file named lastpipe just contain: shopt -s lastpipe exit 142 | false run command: $ strace /bin/bash lastpipe the output: read(3, "shopt -s lastpipe\nexit 142 | fal"..., 80) = 35 lseek(3, 0, SEEK_SET) = 0 getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0 fcntl(255, F_GETFD) = -1 EBADF (Bad file descriptor) dup2(3, 255)= 255 close(3)= 0 fcntl(255, F_SETFD, FD_CLOEXEC) = 0 fcntl(255, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE) fstat(255, {st_mode=S_IFREG|0644, st_size=35, ...}) = 0 lseek(255, 0, SEEK_CUR) = 0 read(255, "shopt -s lastpipe\nexit 142 | fal"..., 35) = 35 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 pipe([3, 4])= 0 rt_sigprocmask(SIG_BLOCK, [INT CHLD], [CHLD], 8) = 0 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fc40e9fb9d0) = 774 rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0 close(4)= 0 close(4)= -1 EBADF (Bad file descriptor) getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0 fcntl(255, F_GETFD) = 0x1 (flags FD_CLOEXEC) fcntl(254, F_GETFD) = -1 EBADF (Bad file descriptor) dup2(0, 254)= 254 close(0)= 0 dup2(3, 0) = 0 close(3)= 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0 rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0 dup2(254, 0)= 0 close(254) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=774, si_uid=0, si_status=142, si_utime=0, si_stime=0} --- wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 142}], WNOHANG, NULL) = 774 wait4(-1, 0x7ffc0efc1658, WNOHANG, NULL) = -1 ECHILD (No child processes) rt_sigreturn({mask=[]}) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGINT, {0x440490, [], SA_RESTORER, 0x7fc40e04b100}, {SIG_DFL, [], SA_RESTORER, 0x7fc40e04b100}, 8) = 0 rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fc40e04b100}, {0x440490, [], SA_RESTORER, 0x7fc40e04b100}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 fstat(2, {st_mode=S_IFCHR|0600, st_rdev=makedev(4, 64), ...}) = 0 ioctl(2, TCGETS, {B115200 opost isig icanon echo ...}) = 0 write(2, "lastpipe: line 3: 774 Exit 142"..., 57lastpipe: line 3: 774 Exit 142exit 142 ) = 57 write(2, " 773 Hangup "..., 43 773 Hangup | false ) = 43 read(255, "", 35) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 exit_group(129) = ? +++ exited with 129 +++ On 2016年08月10日 19:16, Chet Ramey wrote: On 8/10/16 3:32 AM, dengke...@windriver.com wrote: Hi all When I run the bash test lastpipe.tests, there were some errors occurred. The code in lastpipe.tests: shopt -s lastpipe ... exit 142 | false echo $? -- ${PIPESTATUS[@]} The error output: lastpipe.tests: line 41: 708 Exit 142exit 142 703 Hangup | false 129 -- 142 129 I can't reproduce this. It looks system-specific; there shouldn't be anything sending a SIGHUP to a simple command there.
Re: bash test: lastpipe.tests failed
Maybe my linux system have some problem. I have upgrade to the 4.3.46. root@qemux86-64:~# /bin/bash test test: line 3: 1055 Exit 142exit 142 1054 Hangup | false 142 129 root@qemux86-64:~# /bin/bash --version GNU bash, version 4.3.46(1)-release (x86_64-poky-linux-gnu) Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. root@qemux86-64:~# uname -a Linux qemux86-64 4.4.14-yocto-standard #1 SMP PREEMPT Tue Aug 2 06:48:36 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux On 2016年08月12日 21:02, Chet Ramey wrote: On 8/12/16 4:14 AM, dengke...@windriver.com wrote: I used the strace tool to follow it. I touch a file named lastpipe just contain: shopt -s lastpipe exit 142 | false run command:)$ ./bash --version OK. $ ./bash --version GNU bash, version 4.3.46(3)-release (x86_64-unknown-linux-gnu) Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. $ cat x1 shopt -s lastpipe exit 142 | false echo ${PIPESTATUS[@]} $ ./bash ./x1 142 1 $ uname -a Linux chet-mail 2.6.32-642.1.1.el6.x86_64 #1 SMP Fri May 6 14:54:05 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux