OpenWrt 25.12.4 terminal history shows garbled text

Hello,

I run OpenWrt 25.12.4 on Aruba AP-303H
When I try to access terminal history (history command) I see garbled text as below,

I tried on mac (termius app), windows(putty) everywhere same problem.

Same version of openwrt I also run on a raspberry pi 2 where I dont have this problem,

Any thoughts?

Maybe something becomes clear when you redirect it?

history 2>/tmp/history
hexdump -C /tmp/history 

OK. So the output is actually gibberish, it has nothing to do with wrong terminal setting or something like that.
And it's not UTF8.

Are you using the default ash shell?

echo $SHELL
readling $SHELL

should be /bin/ash and busybox. If so, I suppose there is some bug in arm_cortex-a7_neon-vfpv4 busybox.

BTW, it's more convenient to copy the text and paste it in a 'pre-formatted text' block, instead of posting a screenshot. Copying text from a screenshot is hard.

root@OpenWrt-AP:~# echo $SHELL
/bin/ash
root@OpenWrt-AP:~# readling $SHELL
-ash: readling: not found

Ah sorry. 'readling' should be 'readlink'. But at least the shell is not bash, or something like that. I suggest that you file a bug here: https://github.com/openwrt/openwrt/issues

Can you post:

echo $HISTFILE
ls -l $HISTFILE
type history
root@OpenWrt-AP:~# echo $HISTFILE
/tmp/.busybox_ash_history
root@OpenWrt-AP:~# ls -l $HISTFILE
-rw-------    1 root     root        108086 Jun  6 15:06 /tmp/.busybox_ash_history
root@OpenWrt-AP:~# type history
history is a shell builtin

That looks large. Maybe something got corrupted along the way (obviously).

should i delete that file and try again?

Yes, that should be harmless.

Or just reboot.
/tmp is ramdisk (unless you have changed it).

I rebooted and ran some commands and exited the terminal and connected again and history worked correctly.
But if I reboot again, my history is gone. I believe this is expected behavior.
Is there any way to make history persist upon reboot.

See the note in the 25.12.0 release notes OpenWrt 25.12.0 - Stable Release

It is STRONGLY advised to not do frequent writes to basic flash storage as is found in many devices which run OpenWrt. It is recommended to use an expendable drive like an sd-card or usb flash drive, or a durable drive like a hard drive, nvme drive etc.

Busybox is configured to save history only at shell exit, not after each command. So, flash wear would not be that high even after changing the save location from ramdisk to flash.

My original commit implementing the feature in PR https://github.com/openwrt/openwrt/pull/17179 gives info, as well as the release notes of 25.12. You define the history save file in a profile snippet file /etc/profile.d/busybox-history-file.sh. Just edit that to a file that you want, and then also remember to define that file to be backed in sysupgrade.

But like said earlier, the default is ramdisk, to avoid flash wear.