Ping every network address, starting from the last, excluding the broadcast address, excluding the dhcp range addresses, excluding the static ip leases and returns the first address which times out after a 5 second delay.
In my case building a tmpfile script would be quite cumber some, and would require running many commands since you could add less than 512 character per command run.
It appears it is impossible to change the 512 character limit without recompiling ash with a different hardcoded value.
512 character is very stingy !!
Even DOS (well, cmd.exe at least) allows 8131 without issues (8191 if you really push it carefully)
So for now it appears the sane solution is
USER=root && apk add bash && sed -i "s|^${USER}:.*:/bin/ash$|${USER}:x:0:0:${USER}:/root:/bin/bash|" /etc/passwd
@brada4
sorry, I was unclear and equated typing and pasting. In my actual case it neither paste nor type, the command is provided via an ssh client, further complicating the matter. I did not realize the implications at the time.
@frollic
While installing and replacing the shell with bash solved the prior issue. Unfortunately now some of the navigation keys have broken, namely home/end which is very annoying ! I will endeavour to find the solution to this extra paper cut. I wish ash could have its max command line length changed from configuration file !
@dave14305
Could this default value be increase to 8192 (or, gasp, 16384! ) ? Although I appreciate that if I were to run ash on a ESP32 it might actually work, the device I own with the smallest amount of ram is the TP-Link TL-WA901ND and even it comes with a luxurious 32MiB of RAM so I think it can afford this extravagance !
Which means create a DHCP tag called "deadgateway" which sets dhcp option 3 to a value that is the highest value ip host address on the network, excluding the broadcast address, excluding any static lease, excluding the dhcp range which does not respond to a ping with a timeout of 5 second.