mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-28 18:21:52 +00:00
Better error message on unparseable TZ environment variable (#1249)
This commit is contained in:
parent
dc14420f82
commit
2d00b44ead
7 changed files with 7 additions and 4 deletions
|
|
@ -53,7 +53,7 @@ func Main() MainReturn {
|
|||
|
||||
options, recordTransformers, err := climain.ParseCommandLine(os.Args)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, os.Args[0], ": ", err)
|
||||
fmt.Fprintln(os.Stderr, "mlr:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ import (
|
|||
// platform this is necessary for *changing* TZ mid-process: e.g. if a DSL
|
||||
// statement does 'ENV["TZ"] = Asia/Istanbul'.
|
||||
func SetTZFromEnv() error {
|
||||
location, err := time.LoadLocation(os.Getenv("TZ"))
|
||||
tzenv := os.Getenv("TZ")
|
||||
location, err := time.LoadLocation(tzenv)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("TZ environment variable appears malformed: \"%s\"", tzenv)
|
||||
}
|
||||
time.Local = location
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
mlr --tz .../... -n put -f test/input/sec2localtime-tz.mlr
|
||||
|
|
@ -0,0 +1 @@
|
|||
mlr: TZ environment variable appears malformed: ".../..."
|
||||
|
|
@ -1 +1 @@
|
|||
${MLR} : unknown time zone this-is-not-a-valid-timezone-name
|
||||
mlr: TZ environment variable appears malformed: "this-is-not-a-valid-timezone-name"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue