Subject: bug#35639: 27.0.50; tramp fails to use ssh on LibreCMC (no base64 encoder available, and not mentioned in tramp manual)

From: Jeronimo Pellegrini <[email-masked]>
Date: Fri, 10 May 2019 11:45:46 -0300

Hi,

On Fri, May 10, 2019 at 12:18:17PM +0200, Michael Albinus wrote:
> Jeronimo Pellegrini <[email-masked]> writes:
> > What do we do? Duplicate the functions again?
> ( ... )
> 
> Maybe, we shall use just a template for the encoding/decoding functions,
> and for all busybox subcommands we need a test, whether they can be
> invoked via "busybox command" or "command". There will be sevaeral
> combinations to test.

If templating is the way to go, then tramp-od-awk-encode,
tramp-hexdump-awk-encode, tramp-awk-decode would not be constant
strings anymore; a string would need to be build every time tramp
started a connection. Tramp would apply tests, and depending on
what tests succeed, concatenate the proper strings. Is this good?

Or I can try to make the shell code that is sent to the remote
end do the verification itself (I'd test using dash, which I
hope will work on most systems of interest). Something like

{ hexdump < /dev/null && HD=hexdump; } || \
{ busybox hexdump < /dev/null && HD="busybox hexdump"; } &&  \
$HD ...

(but including the proper command line arguments)

This would work on dash, bash, zsh, ksh and hopefully on any shell
that claims to be POSIX-compliant. Won't work on fish and any
other fancy, modern, alternative shells, of course.

Which one is preferable? Templating in emacs-lisp, or creating smart
shell code?

J.