From 9908f8c289fd0d93b3d10afc3a69eb836083676f Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 11 May 2017 21:01:23 +0100 Subject: [PATCH] Do not insert empty or duplicate entries into shell history If a string is empty or the same as the previous command then it will not be inserted into history. --- src/main/resources/assets/computercraft/lua/rom/programs/lua | 4 +++- .../resources/assets/computercraft/lua/rom/programs/shell | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/lua b/src/main/resources/assets/computercraft/lua/rom/programs/lua index edff066c0..2569bf69b 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/lua @@ -44,7 +44,9 @@ while bRunning do end return nil end ) - table.insert( tCommandHistory, s ) + if s:match("%S") and tCommandHistory[#tCommandHistory] ~= s then + table.insert( tCommandHistory, s ) + end local nForcePrint = 0 local func, e = load( s, "lua", "t", tEnv ) diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/shell b/src/main/resources/assets/computercraft/lua/rom/programs/shell index 3bcec92df..59728ed62 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/shell +++ b/src/main/resources/assets/computercraft/lua/rom/programs/shell @@ -363,7 +363,9 @@ else else sLine = read( nil, tCommandHistory ) end - table.insert( tCommandHistory, sLine ) + if sLine:match("%S") and tCommandHistory[#tCommandHistory] ~= sLine then + table.insert( tCommandHistory, sLine ) + end shell.run( sLine ) end end