修正命令行退格显示错误
This commit is contained in:
@@ -19,7 +19,7 @@ select_language() {
|
||||
echo -e "${YELLOW}2. English${NC}"
|
||||
echo -e "${CYAN}==========================================${NC}"
|
||||
echo -n -e "${PURPLE}请选择语言 / Please select language [1-2]: ${NC}"
|
||||
read lang_choice
|
||||
read -r lang_choice
|
||||
|
||||
case $lang_choice in
|
||||
1)
|
||||
@@ -42,7 +42,7 @@ select_language() {
|
||||
# 定义语言数组
|
||||
# 中文
|
||||
declare -A LANG_ZH_CN=(
|
||||
[title]="Ubuntu 命令行工具"
|
||||
[title]="Linux 命令行工具"
|
||||
[copyright]="四喜科技 免费提供"
|
||||
[website]="官方网址:https://xi.plus"
|
||||
[menu_1]="1. 查看系统信息"
|
||||
@@ -79,7 +79,7 @@ declare -A LANG_ZH_CN=(
|
||||
|
||||
# 英文
|
||||
declare -A LANG_EN=(
|
||||
[title]="Ubuntu Command Line Tool"
|
||||
[title]="Linux Command Line Tool"
|
||||
[copyright]="Provided by Sixi Technology"
|
||||
[website]="Official Website: https://xi.plus"
|
||||
[menu_1]="1. View System Info"
|
||||
@@ -114,6 +114,27 @@ declare -A LANG_EN=(
|
||||
[please_continue]="Press any key to continue..."
|
||||
)
|
||||
|
||||
# 配置终端,确保退格键正常工作
|
||||
configure_terminal() {
|
||||
# 保存当前终端设置
|
||||
original_stty=$(stty -g)
|
||||
# 配置终端,将退格键映射为^H
|
||||
stty erase ^H
|
||||
stty werase ^W
|
||||
stty kill ^U
|
||||
}
|
||||
|
||||
# 恢复终端设置
|
||||
restore_terminal() {
|
||||
stty "$original_stty"
|
||||
}
|
||||
|
||||
# 保存原始终端设置
|
||||
trap restore_terminal EXIT
|
||||
|
||||
# 配置终端
|
||||
configure_terminal
|
||||
|
||||
# 语言选择
|
||||
select_language
|
||||
if [ $? -eq 0 ]; then
|
||||
@@ -268,7 +289,7 @@ network_tools() {
|
||||
echo -e "${YELLOW}0. 返回主菜单${NC}"
|
||||
echo -e "${CYAN}==========================================${NC}"
|
||||
echo -n -e "${PURPLE}请输入您的选择 [0-10]: ${NC}"
|
||||
read net_choice
|
||||
read -r net_choice
|
||||
|
||||
case $net_choice in
|
||||
1)
|
||||
@@ -306,7 +327,7 @@ network_tools() {
|
||||
fi
|
||||
|
||||
echo -n -e "${PURPLE}请输入要扫描的目标IP或域名: ${NC}"
|
||||
read target
|
||||
read -r target
|
||||
|
||||
echo -e "${YELLOW}开始扫描目标 ${target}...${NC}"
|
||||
sudo nmap -sS -p 1-1000 $target
|
||||
@@ -325,7 +346,7 @@ network_tools() {
|
||||
echo -e "${YELLOW}1. 使用 netstat 查看${NC}"
|
||||
echo -e "${YELLOW}2. 使用 ss 查看${NC}"
|
||||
echo -n -e "${PURPLE}请选择工具 [1-2]: ${NC}"
|
||||
read conn_tool
|
||||
read -r conn_tool
|
||||
|
||||
case $conn_tool in
|
||||
1)
|
||||
@@ -372,7 +393,7 @@ network_tools() {
|
||||
fi
|
||||
|
||||
echo -n -e "${PURPLE}请输入要测试的域名: ${NC}"
|
||||
read domain
|
||||
read -r domain
|
||||
|
||||
echo -e "${YELLOW}开始DNS测试...${NC}"
|
||||
dig $domain
|
||||
@@ -396,7 +417,7 @@ network_tools() {
|
||||
fi
|
||||
|
||||
echo -n -e "${PURPLE}请输入要追踪的目标IP或域名: ${NC}"
|
||||
read target
|
||||
read -r target
|
||||
|
||||
echo -e "${YELLOW}开始路由追踪...${NC}"
|
||||
traceroute $target
|
||||
@@ -413,10 +434,10 @@ network_tools() {
|
||||
echo -e "${CYAN}==========================================${NC}"
|
||||
|
||||
echo -n -e "${PURPLE}请输入要ping的目标IP或域名: ${NC}"
|
||||
read target
|
||||
read -r target
|
||||
|
||||
echo -n -e "${PURPLE}请输入ping的次数(默认4次): ${NC}"
|
||||
read count
|
||||
read -r count
|
||||
count=${count:-4}
|
||||
|
||||
echo -e "${YELLOW}开始Ping测试...${NC}"
|
||||
@@ -441,7 +462,7 @@ network_tools() {
|
||||
fi
|
||||
|
||||
echo -n -e "${PURPLE}请输入要解析的域名: ${NC}"
|
||||
read domain
|
||||
read -r domain
|
||||
|
||||
echo -e "${YELLOW}开始域名解析测试...${NC}"
|
||||
nslookup $domain
|
||||
@@ -530,7 +551,7 @@ system_config() {
|
||||
echo -e "${YELLOW}0. 返回主菜单${NC}"
|
||||
echo -e "${CYAN}==========================================${NC}"
|
||||
echo -n -e "${PURPLE}请输入您的选择 [0-6]: ${NC}"
|
||||
read config_choice
|
||||
read -r config_choice
|
||||
|
||||
case $config_choice in
|
||||
1)
|
||||
@@ -620,7 +641,7 @@ system_config() {
|
||||
echo -e "${YELLOW}1. 查看所有服务状态${NC}"
|
||||
echo -e "${YELLOW}2. 查看特定服务状态${NC}"
|
||||
echo -n -e "${PURPLE}请选择 [1-2]: ${NC}"
|
||||
read service_choice
|
||||
read -r service_choice
|
||||
|
||||
case $service_choice in
|
||||
1)
|
||||
@@ -630,7 +651,7 @@ system_config() {
|
||||
;;
|
||||
2)
|
||||
echo -n -e "${PURPLE}请输入服务名称: ${NC}"
|
||||
read service_name
|
||||
read -r service_name
|
||||
echo -e "${YELLOW}服务 ${service_name} 状态:${NC}"
|
||||
systemctl status $service_name
|
||||
log_message "INFO" "查看服务状态,服务名称: $service_name"
|
||||
@@ -835,7 +856,7 @@ system_update() {
|
||||
|
||||
echo -e "\n${YELLOW}1. 自动更新${NC}"
|
||||
echo -n -e "${PURPLE}请输入您的选择 [1]: ${NC}"
|
||||
read update_choice
|
||||
read -r update_choice
|
||||
|
||||
case $update_choice in
|
||||
1)
|
||||
@@ -939,7 +960,7 @@ configure_rinetd() {
|
||||
echo -e "${YELLOW}0. 返回主菜单${NC}"
|
||||
echo -e "${CYAN}==========================================${NC}"
|
||||
echo -n -e "${PURPLE}请输入您的选择 [0-4]: ${NC}"
|
||||
read rinetd_choice
|
||||
read -r rinetd_choice
|
||||
|
||||
case $rinetd_choice in
|
||||
1)
|
||||
@@ -964,20 +985,20 @@ configure_rinetd() {
|
||||
echo -e "${CYAN}==========================================${NC}"
|
||||
|
||||
echo -n -e "${PURPLE}输入本地IP(默认0.0.0.0): ${NC}"
|
||||
read local_ip
|
||||
read -r local_ip
|
||||
local_ip=${local_ip:-0.0.0.0}
|
||||
|
||||
echo -n -e "${PURPLE}输入本地端口: ${NC}"
|
||||
read local_port
|
||||
read -r local_port
|
||||
|
||||
echo -n -e "${PURPLE}输入目标域名: ${NC}"
|
||||
read target_domain
|
||||
read -r target_domain
|
||||
|
||||
echo -n -e "${PURPLE}输入目标端口: ${NC}"
|
||||
read target_port
|
||||
read -r target_port
|
||||
|
||||
echo -n -e "${PURPLE}是否添加到配置文件?(y/n,默认y): ${NC}"
|
||||
read add_to_file
|
||||
read -r add_to_file
|
||||
add_to_file=${add_to_file:-y}
|
||||
|
||||
if [ "$add_to_file" == "y" ] || [ "$add_to_file" == "Y" ]; then
|
||||
@@ -1005,7 +1026,7 @@ configure_rinetd() {
|
||||
sudo awk '{print NR ". " $0}' /etc/rinetd.conf
|
||||
|
||||
echo -n -e "${PURPLE}输入要修改的配置项序号: ${NC}"
|
||||
read config_num
|
||||
read -r config_num
|
||||
|
||||
# 获取当前配置行
|
||||
current_config=$(sudo sed -n "${config_num}p" /etc/rinetd.conf)
|
||||
@@ -1018,23 +1039,23 @@ configure_rinetd() {
|
||||
current_target_port=$(echo $current_config | awk '{print $4}')
|
||||
|
||||
echo -n -e "${PURPLE}输入新的本地IP(默认$current_local_ip): ${NC}"
|
||||
read new_local_ip
|
||||
read -r new_local_ip
|
||||
new_local_ip=${new_local_ip:-$current_local_ip}
|
||||
|
||||
echo -n -e "${PURPLE}输入新的本地端口(默认$current_local_port): ${NC}"
|
||||
read new_local_port
|
||||
read -r new_local_port
|
||||
new_local_port=${new_local_port:-$current_local_port}
|
||||
|
||||
echo -n -e "${PURPLE}输入新的目标域名(默认$current_target_domain): ${NC}"
|
||||
read new_target_domain
|
||||
read -r new_target_domain
|
||||
new_target_domain=${new_target_domain:-$current_target_domain}
|
||||
|
||||
echo -n -e "${PURPLE}输入新的目标端口(默认$current_target_port): ${NC}"
|
||||
read new_target_port
|
||||
read -r new_target_port
|
||||
new_target_port=${new_target_port:-$current_target_port}
|
||||
|
||||
echo -n -e "${PURPLE}是否保存修改?(y/n,默认y): ${NC}"
|
||||
read save_changes
|
||||
read -r save_changes
|
||||
save_changes=${save_changes:-y}
|
||||
|
||||
if [ "$save_changes" == "y" ] || [ "$save_changes" == "Y" ]; then
|
||||
@@ -1069,14 +1090,14 @@ configure_rinetd() {
|
||||
sudo awk '{print NR ". " $0}' /etc/rinetd.conf
|
||||
|
||||
echo -n -e "${PURPLE}输入要删除的配置项序号: ${NC}"
|
||||
read config_num
|
||||
read -r config_num
|
||||
|
||||
# 检查配置项是否存在
|
||||
current_config=$(sudo sed -n "${config_num}p" /etc/rinetd.conf)
|
||||
|
||||
if [ -n "$current_config" ]; then
|
||||
echo -n -e "${PURPLE}是否删除该配置项?(y/n,默认y): ${NC}"
|
||||
read delete_config
|
||||
read -r delete_config
|
||||
delete_config=${delete_config:-y}
|
||||
|
||||
if [ "$delete_config" == "y" ] || [ "$delete_config" == "Y" ]; then
|
||||
@@ -1114,7 +1135,7 @@ configure_rinetd() {
|
||||
# 主循环
|
||||
while true; do
|
||||
show_menu
|
||||
read choice
|
||||
read -r choice
|
||||
|
||||
case $choice in
|
||||
1)
|
||||
|
||||
Reference in New Issue
Block a user