Created attachment 6611 [details] Config file used to build Busybox Busybox version 1.25, running in OpenWRT. When the sha256sum command is executed in a script, all the following commands in the script are executed, and then they are all executed a second time. There is no loop in the script. A workaround is to put the sha256sum command into a little script by itself, and to call that script from the main script. Example script: #!/bin/sh echo START #tar tvJf /dev/mtd3 sha256sum -c app.sha256 echo MIDDLE echo END Executing this script produces the following output: START sha256sum: app.sha256: No such file or directory MIDDLE END MIDDLE END
The Busybox version is actually 1.26.0.git (2016-08-17 09:15:25 BST)
Fixed in git, please try it: commit 215b0ca6e4fe466c6942d21a1bba62d97f2d5e5d Author: Denys Vlasenko <vda.linux@googlemail.com> Date: Fri Aug 19 18:23:56 2016 +0200 hush: fix a bug in FEATURE_SH_STANDALONE=y config. Closes 9186 Run this in a "sh SCRIPT": sha256sum /dev/null echo END sha256sum is a NOEXEC applet. It runs in a forked child. Then child exit()s. By this time, entire script is read, and buffered in a FILE object from fopen("SCRIPT"). But fgetc() did not consume entire input. exit() lseeks back by -9 bytes, from <eof> to 'e' in 'echo'. (this may be libc-specific). This change of fd position *is shared with the parent*! Now parent can read more, and it thinks there is another "echo END". End result: two "echo END"s are run. Fix this by _exit()ing instead.
Yes, that fixes it. Thank you for your impressively fast response.