busybox: Save shell history into /tmp
authorHannu Nyman <hannu.nyman@iki.fi>
Thu, 5 Dec 2024 20:28:45 +0000 (22:28 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 8 Dec 2024 18:18:02 +0000 (19:18 +0100)
Enable the busybox feature to save shell command history.
(.apk size increase 0.5 kB)

To prevent flash wear,
* save history only at the exit from a shell session, and
* set /tmp as the default location for the history file. The history
  is kept on ramdisk until a reboot, when the history is then lost.

If the user wants to save history onto flash, he can change the location
definition in /etc/profile.d/busybox-history-file.sh

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
Link: https://github.com/openwrt/openwrt/pull/17179
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
package/utils/busybox/Config-defaults.in
package/utils/busybox/Makefile
package/utils/busybox/files/busybox-history-file.sh [new file with mode: 0644]

index 26d3e642ce7b89da39a3ec17d08b831df47efeaa..820c498eeade560fd03d7806428a398a182dfd90 100644 (file)
@@ -255,10 +255,10 @@ config BUSYBOX_DEFAULT_FEATURE_EDITING_HISTORY
        default 256
 config BUSYBOX_DEFAULT_FEATURE_EDITING_SAVEHISTORY
        bool
-       default n
+       default y
 config BUSYBOX_DEFAULT_FEATURE_EDITING_SAVE_ON_EXIT
        bool
-       default n
+       default y
 config BUSYBOX_DEFAULT_FEATURE_REVERSE_SEARCH
        bool
        default n
index 4f155b7a2503b24fe73fe680125bafb3f01a23b2..c2fc609610e80ab6ab9ea720ae0c3c419e406acf 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=busybox
 PKG_VERSION:=1.37.0
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_FLAGS:=essential
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
@@ -143,6 +143,8 @@ define Package/busybox/install
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_DIR) $(1)/usr/sbin
        $(CP) $(PKG_INSTALL_DIR)/* $(1)/
+       $(INSTALL_DIR) $(1)/etc/profile.d
+       $(INSTALL_BIN) ./files/busybox-history-file.sh $(1)/etc/profile.d
 ifneq ($(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_FEATURE_SYSLOG)$(CONFIG_BUSYBOX_$(BUSYBOX_SYM)_FEATURE_SYSLOGD_CFG),)
        touch $(1)/etc/syslog.conf
 endif
diff --git a/package/utils/busybox/files/busybox-history-file.sh b/package/utils/busybox/files/busybox-history-file.sh
new file mode 100644 (file)
index 0000000..f286009
--- /dev/null
@@ -0,0 +1,2 @@
+export HISTFILE=/tmp/.busybox_ash_history
+