diff --git a/lib/tput.js b/lib/tput.js index ead7c5b..ec25651 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -163,22 +163,41 @@ Tput._tprefix = Tput.prototype._tprefix = function(prefix, term) { if (!prefix) return; + var file + , ch; + if (!term) { file = path.resolve(prefix, 'x'); try { fs.statSync(file); return prefix; } catch (e) { - return; + ; } + file = path.resolve(prefix, '78'); + try { + fs.statSync(file); + return prefix; + } catch (e) { + ; + } + return; } - var file = path.resolve( - prefix, - path.basename(term[0]), - path.basename(term) - ); + term = path.basename(term); + file = path.resolve(prefix, term[0], term); + try { + fs.statSync(file); + return file; + } catch (e) { + ; + } + + ch = term[0].charCodeAt(0).toString(16); + if (ch.length < 2) ch = '0' + ch; + + file = path.resolve(prefix, ch, term); try { fs.statSync(file); return file;