[PATCH v2 6/7] coreutils: Import from packages feed

Christian Marangi ansuelsmth at gmail.com
Mon Jan 9 11:20:58 PST 2023


On Mon, Jan 09, 2023 at 03:35:56PM +0100, Petr Štetiar wrote:
> Petr Štetiar <ynezz at true.cz> [2023-01-09 11:50:37]:
> 
> Hi,
> 
> > BTW ucode has `b64dec()`[1] so perhaps another viable option.
> > 
> > 1. https://github.com/jow-/ucode#663-b64decstr
> 
> wanted to refresh my ucode brain cells, so I've explored feasibility of that
> suggestion and it seems to work just fine:
> 
> 	#!/usr/bin/ucode
> 
> 	import { stdin, open, error } from 'fs';
> 
> 	if (length(ARGV) == 0 && stdin.isatty()) {
> 		warn("usage: b64decode [stdin|path]\n");
> 		exit(1);
> 	}
> 
> 	let fp = stdin;
> 	let source = ARGV[0];
> 
> 	if (source) {
> 		fp = open(source);
> 		if (!fp) {
> 			warn(`b64decode: unable to open ${source}: ${error()}\n`);
> 			exit(1);
> 		}
> 	}
> 
> 	print(b64dec(fp.read("all")));
> 	fp.close();
> 	exit(0);
> 
> BTW it needs recent ucode with fs.stdin.isatty() support[1].
> 
> Thanks Jo for helping me making above script more idiomatic. IMO it looks more
> human readable, portable and maintanable then that awk based solution.
> 
> 1. https://github.com/jow-/ucode/commit/be30472bfdbbb410e8934b48a56d26c5c630d0f1
> 

Thanks for helping with this. I really like the ucode way. Just a few
question:
1. How this should be handled? A script that the target will provide?
Part of a common function?

2. Ucode is part of the core packages? Or an optional dependency for
luci and fw4? In theory it should be always present or as a safe thing
we should add ucode in the required packages for this target?


-- 
	Ansuel



More information about the openwrt-devel mailing list