Skip to content

Commit d3ab9c6

Browse files
committed
♻️ Refactor to Use Readline
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
1 parent 2bd678c commit d3ab9c6

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

safe_hashes.sh

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,42 +1352,8 @@ EOF
13521352
value="${value_input:-$value}"
13531353
validate_value $value "value"
13541354

1355-
# Display data separately to avoid terminal buffer issues with large calldata
1356-
echo "Default \`data\` value:"
1357-
echo "How would you like to provide the \`data\`?"
1358-
echo " 1) Use default value shown above (press Enter)"
1359-
echo " 2) Enter/paste data directly"
1360-
echo " 3) Read from a file"
1361-
read -rp "Choose an option (1/2/3): " data_option
1362-
data_option="${data_option:-1}"
1363-
1364-
case "$data_option" in
1365-
1)
1366-
# Use default
1367-
;;
1368-
2)
1369-
echo "Enter the \`data\` (for large data, consider using option 3):"
1370-
# Read without prompt to avoid buffer issues
1371-
IFS= read -r data_input
1372-
if [[ -n "$data_input" ]]; then
1373-
data="$data_input"
1374-
fi
1375-
;;
1376-
3)
1377-
read -rp "Enter the file path containing the data: " data_file
1378-
if [[ -f "$data_file" ]]; then
1379-
# Read the entire file content, removing any whitespace/newlines
1380-
data=$(tr -d '[:space:]' < "$data_file")
1381-
echo "Data loaded from file: ${data:0:66}..." # Show first 66 chars
1382-
else
1383-
echo "${RED}Error: File not found: $data_file${RESET}"
1384-
echo "Using default value instead."
1385-
fi
1386-
;;
1387-
*)
1388-
echo "${YELLOW}Invalid option. Using default value.${RESET}"
1389-
;;
1390-
esac
1355+
read -erp "Enter the \`data\` (default: $data): " data_input
1356+
data="${data_input:-$data}"
13911357

13921358
while true; do
13931359
read -rp "Enter the \`operation\` (default: $operation; 0 = CALL, 1 = DELEGATECALL): " operation_input

0 commit comments

Comments
 (0)