I
I
Ilya Myasin2017-04-19 17:26:13
css
Ilya Myasin, 2017-04-19 17:26:13

Why are there duplicate letters in the output of shell_exec('man whoami') on os x?

Hey! I accidentally noticed such a strange thing, it doesn’t interfere with life, but I want to understand the nature of the phenomenon just in case.
Macbook has php 5.6 / nginx / php-fmp. We create a file:

<?php
echo "<pre>";
echo phpversion();
echo shell_exec('man whoami');

And we get this output:
5.6.24
WHOAMI(1) BSD General Commands Manual WHOAMI(1)
NNAAMMEE
wwhhooaammii -- display effective user id
SSYYNNOOPPSSIISS
wwhhooaammii
DDEESSCCRRIIPPTTIIOONN
The wwhhooaammii utility has been obsoleted by the id(1) utility, and is equiva-
lent to ``iidd - -uunn''. The command ``iidd --pp'' is suggested for normal
interactive use.
The wwhhooaammii utility displays your effective user ID as a name.
EEXXIITT SSTTAATTUUSS
The wwhhooaammii utility exits 0 on success, and >0 if an error occurs.
SSEEEE AALLSSOO
id(1)
BSD June 6, 1993 BSD

Letters are duplicated in the headings and in the team name in the text. If you type 'man whoami' in the console, everything is fine. I tried to specify the full path to man, the result is similar.
Moreover, if you execute the same code in the console php through the terminal:
php -r 'echo phpversion(); echo shell_exec("man whoami");'

The output will be normal:
5.6.24
WHOAMI(1) BSD General Commands Manual WHOAMI(1)
NAME
whoami -- display effective user id
SYNOPSIS
whoami
DESCRIPTION
The whoami utility has been obsoleted by the id(1) utility, and is equiv-
alent to ``id - un''. The command ``id -p'' is suggested for normal
interactive use.
The whoami utility displays your effective user ID as a name.
EXIT STATUS
The whoami utility exits 0 on success, and >0 if an error occurs.
SEE ALSO
id(1)
BSD June 6, 1993 BSD

I tried to reproduce it on a Debian server, it does not reproduce. What could be the problem, who faced what to pick?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sonca-ca, 2018-04-30
@IckiSanZ

Initially, you have a message about the layout, when there is a problem with the caps, you change the message, but when there is a new problem with the layout after the caps, the text does not change and what was displayed

if (isCyrillic(keyName)) { //вывод сообщения о не правильной раскладке
   //нужно добавить
    var modalWindowCaps = document.getElementById("alertWindowText");
    modalWindowCaps.innerHTML = ("Раскладка!");
    ...
}  else if (capsLockEnabled && keyName != null) {
    var modalWindowCaps = document.getElementById("alertWindowText");
    modalWindowCaps.innerHTML = ("Включен CapsLock!");
    ...
}

R
Rsa97, 2017-04-19
@dubr

If you look at the source text (/usr/share/man/man1/...), you will see that there is a BS code (\x08) between the duplicate characters. This came from printers, when a bold character could be obtained by going back one character (BackSpace) and reprinting it.
In the console, different programs handle this character differently, hence the difference in output.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question