Skip to content

Commit 4d49837

Browse files
committed
do not startup if files are not found
1 parent abccd10 commit 4d49837

5 files changed

Lines changed: 16 additions & 7 deletions

File tree

src/base/fs_util.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ determine_path_type(const std::string& arg)
206206
return path_type::url;
207207
}
208208

209-
switch (arg.find(':')) {
210-
case 0:
211-
return path_type::normal;
212-
case 1:
213-
return path_type::windows;
214-
default:
215-
return path_type::remote;
209+
const auto colon_pos = arg.find(':');
210+
if (colon_pos == std::string::npos) {
211+
return path_type::normal;
212+
}
213+
if (colon_pos == 1) {
214+
return path_type::windows;
216215
}
216+
return path_type::remote;
217217
}
218218

219219
path_transcoder

test/expected/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ dist_noinst_DATA = \
88
test_cli.sh_0b3639753916f71254e8c9cce4ebb8bfd9978d3e.out \
99
test_cli.sh_10c33e465ef7681c6b5519d05d557426b26cd43d.err \
1010
test_cli.sh_10c33e465ef7681c6b5519d05d557426b26cd43d.out \
11+
test_cli.sh_1507a515f62dfc9ad0af85decadbd7921be9b96d.err \
12+
test_cli.sh_1507a515f62dfc9ad0af85decadbd7921be9b96d.out \
1113
test_cli.sh_17a68b798354f9a6cdfab372006caeb74038d15c.err \
1214
test_cli.sh_17a68b798354f9a6cdfab372006caeb74038d15c.out \
1315
test_cli.sh_1ec76eb2416d2c09c13eba62ff8bcf920a888b9c.err \
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
✘ error: unable to open file: badfilename
2+
reason: No such file or directory
3+
✘ error: unable to display interactive text UI
4+
reason: stdout is not a TTY
5+
 = help: pass the -n option to run lnav in headless mode or don't redirect stdout

test/expected/test_cli.sh_1507a515f62dfc9ad0af85decadbd7921be9b96d.out

Whitespace-only changes.

test/test_cli.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export YES_COLOR=1
55

66
run_cap_test ${lnav_test} -h
77

8+
run_cap_test ${lnav_test} badfilename
9+
810
run_cap_test ${lnav_test} -n -c 'foo'
911

1012
run_cap_test ${lnav_test} -d /tmp/lnav.err -n <<EOF

0 commit comments

Comments
 (0)