From 058cb266261ce227480f301dee3934baedd8273c Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Sat, 20 Aug 2022 00:30:18 +0900 Subject: [PATCH] create histfilesize --- histfilesize/.bashrc | 1 + histfilesize/README.md | 21 +++++++++++++++++++++ histfilesize/compose.yml | 5 +++++ 3 files changed, 27 insertions(+) create mode 100644 histfilesize/.bashrc create mode 100644 histfilesize/README.md create mode 100644 histfilesize/compose.yml diff --git a/histfilesize/.bashrc b/histfilesize/.bashrc new file mode 100644 index 0000000..fb52921 --- /dev/null +++ b/histfilesize/.bashrc @@ -0,0 +1 @@ +HISTFILESIZE=16777215 diff --git a/histfilesize/README.md b/histfilesize/README.md new file mode 100644 index 0000000..3cf0045 --- /dev/null +++ b/histfilesize/README.md @@ -0,0 +1,21 @@ +# Bash `HISTFILESIZE` の限界 + +```console +$ seq 0 $((0x7fffffff)) > .bash_history +$ wc -l .bash_history +2147483648 .bash_history +$ echo $((0x7fffffff)) +2147483647 +$ docker compose run --rm bash +root@ff1161946537:/# 225859065 +$ wc -l .bash_history +16777215 .bash_history +``` + +- 225859066 行 (< 0x7fffffff bytes) まで読み込まれた + - `HISTFILESIZE=$((0x7fffffff))` 以上にするのは意味がない +- `HISTFILESIZE=$((0x7fffff))` 行に切り落とせる +- `HISTFILESIZE=$((0xffffff))` 行に切り落とせる +- `HISTFILESIZE=$((0x7fffffff))` では .bash_history が大きいとハングすることがあった + - このあたりが限界だろう + - 0xffffff 行くらいまでならおそらく OK だろう diff --git a/histfilesize/compose.yml b/histfilesize/compose.yml new file mode 100644 index 0000000..5370a1b --- /dev/null +++ b/histfilesize/compose.yml @@ -0,0 +1,5 @@ +services: + bash: + image: ubuntu:jammy + volumes: + - "./:/root"