2017-02-26 51 views
1

我正在一個CLI界面上運行時出現故障,並想獲得當前正在使用的終端的列數。爲什麼:io.columns通過escript

我發現the documentation for :io.columns,它的工作原理是IEX中的魅力,但一旦我編譯混合的escript二進制文件,通過運行mix escript.build,我運行它,然後:io.columns回報{error, enotsup}

正在發生的事情是,IO設備未正確冒泡?我如何訪問列號?

+0

這可能是[錯誤影響二郎的最新版本(http://erlang.org/pipermail/erlang-questions/2017-September/093 270.html)。 – Janosch

回答

1

有沒有發現爲什麼它不工作,但我會後我使用的解決方案:直接談話抨擊

$ tput cols給出的列數,在bash,所以

對於靈藥:System.cmd("tput", ["cols"])
對於二郎::os.cmd('tput cols')

+0

的Mac系統: 二郎/ OTP 20 [專家評審組-9.0.4] [源] [64位] [SMP:4:4] [DS:4:4:10] [異步線程:0] [HIPE ] [內核輪詢:假] [則dtrace] ESHELL V9.0.4(用1μg中止) ([email protected])1> OS:CMD( 「tput的COLS」)。 「80 \ n」 ([email protected])2> io:columns()。 【OK,141} 但慶典 $ tput的COLS ' – kevin