Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokenize fails with busybox 1.11.2 #50

Open
wvengen opened this issue Dec 24, 2016 · 2 comments
Open

Tokenize fails with busybox 1.11.2 #50

wvengen opened this issue Dec 24, 2016 · 2 comments

Comments

@wvengen
Copy link

wvengen commented Dec 24, 2016

Running on an embedded system with Busybox 1.11.2, any input fails:

$ echo {} | ./JSON.sh
EXPECTED string GOT EOF

$ egrep --version
egrep: unrecognized option `--version'
BusyBox v1.11.2 (2016-05-23 16:56:16 EEST) multi-call binary

No help available.
$ busybox --help
BusyBox v1.11.2 (2016-05-23 16:56:16 EEST) multi-call binary
Copyright (C) 1998-2008 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.

Usage: busybox [function] [arguments]...
   or: function [arguments]...

	BusyBox is a multi-call binary that combines many common Unix
	utilities into a single executable.  Most people will create a
	link to busybox for each function they wish to use and BusyBox
	will act like whatever it was invoked as!

Currently defined functions:
	[, [[, adjtimex, arping, ash, awk, basename, brctl, bunzip2, bzcat, cat, chgrp, chmod, chown, chroot, clear, cp, crond, crontab, cut, date, dd, df, diff, dirname,
	dmesg, du, echo, egrep, env, expr, false, fgrep, find, free, garp, getty, grep, gunzip, gzip, halt, head, hexdump, hostid, hwclock, id, ifconfig, init, insmod,
	kill, killall, killall5, klogd, length, less, ln, lock, logger, login, logread, ls, lsmod, md5sum, mesg, mkdir, mkfifo, mknod, mktemp, mount, mv, nc, netmsg,
	netstat, nice, nslookup, passwd, pgrep, pidof, ping, ping6, pivot_root, pkill, poweroff, printf, ps, pwd, pwdog, rdate, realpath, reboot, reset, rm, rmdir,
	rmmod, route, sed, seq, sh, sleep, sort, start-stop-daemon, strings, switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time,
	top, touch, tr, traceroute, true, udhcpc, umount, uname, uniq, uptime, uudecode, uuencode, vconfig, vi, watchdog, wc, wget, which, xargs, yes, zcat, zcip

Then I looked at tokenization only. Sourcing JSON.sh doesn't work (still expecting input), so I changed the last lines like this:

#if ([ "$0" = "$BASH_SOURCE" ] || ! [ -n "$BASH_SOURCE" ]);
#then
#  parse_options "$@"
#  tokenize | parse
#fi
parse_options "$@"
tokenize

What then happens, is:

$ echo {} | shinc/JSON.sh
{
$ echo '{"foo": 1234, "bar":{"something": "hi there"}}' | shinc/JSON.sh
{

Running all tests indeed shows failures.

@wvengen
Copy link
Author

wvengen commented Dec 24, 2016

I've tested with a newer version of busybox 1.21.1 from https://busybox.net/downloads/binaries/latest/
Adding this busybox'es egrep and grep to PATH lets it work. So the problem must be the (older) grep/egrep version in busybox 1.11.1.

@wvengen wvengen changed the title Tokenize fails with busybox Tokenize fails with busybox 1.11.2 Dec 24, 2016
wvengen added a commit to wvengen/unifi-controllable-switch that referenced this issue Dec 26, 2016
wvengen added a commit to wvengen/unifi-controllable-switch that referenced this issue Dec 27, 2016
@dominictarr
Copy link
Owner

@wvengen if we can change the grep commands to something that works across versions we can merge that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants