shell脚本 如何不用循环语句实现提示输入

带提示的输入

#! /bin/bash

s1(){
    clear
    echo "请输入登录信息"

    if [ ! $username ]
    then
        echo -n "用户名:"
        read username
        s1
        exit 0
    else        
        echo "用户名:"$username        
    fi
    if [ ! $passwd ]
    then
        echo -n "  密码:"
        read passwd
        s1
    else
      echo "  密码:" $passwd
    fi
}

s1
原文地址:https://www.cnblogs.com/allofalan/p/15597343.html