Skip to content

Commit

Permalink
Only warn if locale settings are broken
Browse files Browse the repository at this point in the history
Keep running if calling `setlocale` fails, because of invalid locale settings.
  • Loading branch information
avdv committed Feb 8, 2020
1 parent 7f5e9ab commit 96334da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions lib/colorls/flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def initialize(*args)
end

def process
# initialize locale from environment
CLocale.setlocale(CLocale::LC_COLLATE, '')
init_locale

@args = [Dir.pwd] if @args.empty?
@args.sort!.each_with_index do |path, i|
Expand Down Expand Up @@ -71,6 +70,13 @@ def options

private

def init_locale
# initialize locale from environment
CLocale.setlocale(CLocale::LC_COLLATE, '')
rescue RuntimeError => e
warn "WARN: #{e}"
end

def add_sort_options(options)
options.separator ''
options.separator 'sorting options:'
Expand Down
2 changes: 1 addition & 1 deletion man/colorls.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "COLORLS" "1" "July 2019" "colorls 1.2.0" "colorls Manual"
.TH "COLORLS" "1" "July 2019" "colorls 1.3.3" "colorls Manual"
.
.SH "NAME"
\fBcolorls\fR \- list directory contents with colors and icons
Expand Down

0 comments on commit 96334da

Please sign in to comment.