⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timeout.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bash# timeout.sh#  Written by Stephane Chazelas,#+ and modified by the document author.INTERVAL=5                # timeout intervaltimedout_read() {  timeout=$1  varname=$2  old_tty_settings=`stty -g`  stty -icanon min 0 time ${timeout}0  eval read $varname      # or just  read $varname  stty "$old_tty_settings"  # See man page for "stty".}echo; echo -n "What's your name? Quick! "timedout_read $INTERVAL your_name#  This may not work on every terminal type.#  The maximum timeout depends on the terminal.#+ (it is often 25.5 seconds).echoif [ ! -z "$your_name" ]  # If name input before timeout...then  echo "Your name is $your_name."else  echo "Timed out."fiecho# The behavior of this script differs somewhat from "timed-input.sh".# At each keystroke, the counter resets.exit 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -