mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 17:14:08 +01:00
620 -> 163, with common.sh staying the single entry point that sources its own three parts - the shape the handoff prescribes for config.sh, so all 49 consumers are untouched. Verified by diffing `declare -F` after sourcing it against the same from a detached worktree at HEAD: an identical 48-function set. For a library this widely sourced that is the check that matters, not a passing lint. The FOCUS_APPS_* arrays moved with is_focus_app_running, the only function that reads them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
44 lines
2.8 KiB
JSON
44 lines
2.8 KiB
JSON
{
|
|
"intent": "Split scripts/lib/common.sh, the library 49 scripts source, without changing a single name it exports.",
|
|
"scope": [
|
|
"linux_configuration/scripts/lib/common.sh (620 -> 163)",
|
|
"lib/common_packages.sh, common_services.sh, common_datetime.sh (new)",
|
|
"Non-goal: no behaviour change, no change to the public surface"
|
|
],
|
|
"changes": [
|
|
"common.sh stays the single entry point and now sources its own three parts, exactly the shape the handoff prescribes for phone_focus_mode/config.sh. All 49 consumers keep sourcing one path and need no edit.",
|
|
"Split by concern: user/root/setup helpers stay, focus-app detection and package installation go to common_packages.sh, service control and the log_* family to common_services.sh, and the date/time/uptime helpers to common_datetime.sh.",
|
|
"The FOCUS_APPS_WINDOWS and FOCUS_APPS_PROCESSES arrays moved with is_focus_app_running, the only function that reads them - leaving them behind produced two SC2034 warnings."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "source common.sh in a subshell and diff `declare -F` against the same from a detached worktree at HEAD",
|
|
"result": "pass",
|
|
"evidence": "Identical 48-function set before and after. For a library with 49 consumers this is the check that matters: it proves the public surface is unchanged rather than inferring it from a passing lint."
|
|
},
|
|
{
|
|
"command": "source common.sh and print the array lengths",
|
|
"result": "pass",
|
|
"evidence": "WINDOWS=13 PROCESSES=2 - the arrays are populated, so moving them did not break is_focus_app_running."
|
|
},
|
|
{
|
|
"command": "shellcheck -x common.sh and shellcheck on each part",
|
|
"result": "fail then pass",
|
|
"evidence": "Two SC2034 warnings for the arrays left behind; zero after moving them. No suppression added."
|
|
},
|
|
{
|
|
"command": "meta/scripts/verify_shell_split.sh on convert_video.sh, a real consumer",
|
|
"result": "pass",
|
|
"evidence": "'libs sourced, functions defined' - a script that sources common.sh from two directories up still resolves everything through the new chain."
|
|
}
|
|
],
|
|
"risks": [
|
|
"common.sh is sourced by 49 scripts and by systemd-invoked ones; the function-set diff covers the names, but nothing here executes those 49 scripts. A consumer that relied on a definition ORDER rather than a name would not be caught - the parts are sourced in the original order to keep that safe.",
|
|
"_COMMON_DIR uses ${BASH_SOURCE[0]}, which is required here: common.sh is always sourced, never executed, so $0 would point at the calling script."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; common.sh returns to 620 lines and the three parts disappear.",
|
|
"After rollback, re-run the declare -F diff and expect the same 48 functions."
|
|
]
|
|
}
|