diff options
| author | Mattias Andrée <maandree@operamail.com> | 2015-03-15 16:07:55 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2015-03-15 16:07:55 +0100 |
| commit | bec2764ee58c4ac422a6a2729c61dc6293026ae4 (patch) | |
| tree | 7c83b59aa48e2013c803b8a31a9a3e7e3f013ed8 /gotrc-examples | |
| parent | add +keyboard command (diff) | |
| download | gates-of-tartaros-bec2764ee58c4ac422a6a2729c61dc6293026ae4.tar.gz gates-of-tartaros-bec2764ee58c4ac422a6a2729c61dc6293026ae4.tar.bz2 gates-of-tartaros-bec2764ee58c4ac422a6a2729c61dc6293026ae4.tar.xz | |
fix issue-file1426432257
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'gotrc-examples')
| -rw-r--r-- | gotrc-examples/issue-file | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/gotrc-examples/issue-file b/gotrc-examples/issue-file index fda21a9..6f5aa3f 100644 --- a/gotrc-examples/issue-file +++ b/gotrc-examples/issue-file @@ -18,8 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Module for using the /etc/issue file however -# only partially implemented, but also extended +# Module for using the /etc/issue file _display () @@ -41,17 +40,24 @@ with open("/etc/issue", "rb") as f: uname = os.uname() inet = lambda ip, face = '' : sh("ifconfig %s | grep '^ *%s ' | grep -Po '%s [^ ]*' | cut -d ' ' -f 2 | sed 1q" % (face, ip, ip)) esc = False +skip_arg = False for i in range(len(data)): - c = data[i] - i += 1 - d = '\\n' if i == len(data) else data[i] - def get_arg(): - arg = '' - for j in range(i, len(data)): - arg += data[j] - if arg[-1] == '}': - return arg[1 : -1] - return '' + c = data[i] + i += 1 + if skip_arg: + if c == '}': + skip_arg = False + continue + d = '\\n' if i == len(data) else data[i] + def get_arg(): + global skip_arg + arg = '' + for j in range(i, len(data)): + arg += data[j] + if arg[-1] == '}': + skip_arg = True + return arg[1 : -1] + return '' if esc: esc = False if c in "eE": buf += "\\033" @@ -67,7 +73,7 @@ for i in range(len(data)): elif c == "d": buf += sh("date +%Y-%m-%d") elif c == "t": buf += sh("date +%H:%M:%S") elif c == "l": buf += "${tty}" - elif c == "b": buf += sh("stty | grep -Po 'speed [^ ]* baud;' | cut -d ' ' -f 2") + elif c == "b": buf += sh("stty < '/dev/${tty}' | grep -Po 'speed [^ ]* baud;' | cut -d ' ' -f 2") elif c == "u": buf += sh("who | wc -l") elif c == "U": n = sh('who | wc -l') ; buf += n + (' user' if n == '1' else ' users') elif c == "4": buf += inet('inet', get_arg() if d == '{' else '') @@ -77,11 +83,11 @@ for i in range(len(data)): arg = get_arg() if d == '{' else '' if arg == '': arg = 'PRETTY_NAME' - val = sh('. /etc/os-release ; echo "${%s}"' % arg) + val = sh('. /etc/os-release ; echo "\${%s}"' % arg) if (arg == 'PRETTY_NAME') and (val == ''): val = uname.sysname elif arg == 'ANSI_COLOR': - val = '\033[%sm' % val + val = '\\033[%sm' % val buf += val else: buf += c |
