From 7f7cb66fe5df8c41a2a17bdd87b2ea7964c20066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Fri, 25 Oct 2024 23:02:32 +0900 Subject: [PATCH] fix #103: incorrect output path when input is a single file --- cmd/um/main.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/um/main.go b/cmd/um/main.go index c2d6432..a894f11 100644 --- a/cmd/um/main.go +++ b/cmd/um/main.go @@ -121,13 +121,16 @@ func appMain(c *cli.Context) (err error) { return err } + var inputDir string + if inputStat.IsDir() { + inputDir = input + } else { + inputDir = path.Dir(input) + } + if output == "" { - // Default to where the input is - if inputStat.IsDir() { - output = input - } else { - output = path.Dir(input) - } + // Default to where the input dir is + output = inputDir } outputStat, err := os.Stat(output) @@ -152,7 +155,7 @@ func appMain(c *cli.Context) (err error) { } proc := &processor{ - inputDir: input, + inputDir: inputDir, outputDir: output, skipNoopDecoder: c.Bool("skip-noop"), removeSource: c.Bool("remove-source"),