从 bash 中的命令创建 REPL
Create a REPL out of a command in bash
有没有办法从命令中创建一个简单的 REPL?
我正在使用 dc
计算器,命令的第一部分始终是 dc -e
,所有变化的是要计算的表达式?
我写了一个工具来做这件事:
https://github.com/mchav/with
它制作了一个脚本,将命令包装在一个 while 循环中。例如:
while true ; do
while IFS="" read -r -e -d $'\n' -p '> ' options; do
if [ "$options" = "quit" ]; then
exit 0
else
"" "$options"
fi
done
done
有没有办法从命令中创建一个简单的 REPL?
我正在使用 dc
计算器,命令的第一部分始终是 dc -e
,所有变化的是要计算的表达式?
我写了一个工具来做这件事: https://github.com/mchav/with
它制作了一个脚本,将命令包装在一个 while 循环中。例如:
while true ; do
while IFS="" read -r -e -d $'\n' -p '> ' options; do
if [ "$options" = "quit" ]; then
exit 0
else
"" "$options"
fi
done
done