Skip to content

Commit e076add

Browse files
committed
Fix input reading, banner touch up
1 parent a692aae commit e076add

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

internal/device/device.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,18 @@ func promptForName(out *output.Output, fpath string) (string, error) {
126126
return "", fmt.Errorf("could not get hostname (prompt default): %w", err)
127127
}
128128
hostStub := strings.Split(host, ".")[0]
129-
fmt.Printf("\nPlease choose a short name for this device (default: '%s'): ", hostStub)
130-
var input string
131-
scanner := bufio.NewScanner(os.Stdin)
132-
if scanner.Scan() {
133-
input = scanner.Text()
134-
}
135-
if err = scanner.Err(); err != nil {
136-
return "", fmt.Errorf("scanner error: %w", err)
129+
reader := bufio.NewReader(os.Stdin)
130+
fmt.Printf("\nChoose a short name for this device (default: '%s'): ", hostStub)
131+
input, err := reader.ReadString('\n')
132+
name := strings.TrimRight(input, "\n")
133+
if err != nil {
134+
return "", fmt.Errorf("reader error: %w", err)
137135
}
138-
if input == "" {
136+
if name == "" {
139137
out.Info("Got no input - using default ...")
140-
input = hostStub
138+
name = hostStub
141139
}
142-
out.Info(fmt.Sprintf("Device name set to '%s'", input))
140+
out.Info(fmt.Sprintf("Device name set to '%s'", name))
143141
fmt.Printf("You can change the device name at any time by editing '%s' file\n", fpath)
144142
return input, nil
145143
}

scripts/install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ printf '
187187

188188
# Show banner if RESH is not loaded in the terminal
189189
if [ -z "${__RESH_VERSION-}" ]; then printf '
190-
##############################################################
191-
# #
192-
# Finish the installation by RESTARTING this terminal! #
193-
# #
194-
##############################################################
190+
┌────────────────────────────────────────────────────────────┐
191+
192+
Finish the installation by RESTARTING this terminal!
193+
194+
└────────────────────────────────────────────────────────────┘
195195
'
196196
fi

0 commit comments

Comments
 (0)