쉘이 더 "공격적"일 수 있습니까?

쉘이 더 "공격적"일 수 있습니까?

나의젠투Linux는 다음과 같이 컴파일됩니다.공격사용깃발활성화됨:

# sudo su -
Password: 
Hold it up to the light --- not a brain in sight!
Password: 

선택하는 것도 가능합니다행운공격성의 정도에 따라:

# fortune -o kernelcookies | cowsay -b
 _________________________________________ 
/ /* This is total bullshit: */           \
|                                         |
\ linux-2.6.6/drivers/video/sis/init301.c /
 ----------------------------------------- 
        \   ^__^
         \  (==)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

링크에 제공된 맛 항목 1 의 목록이 짧다는 점을 고려하면 개인적으로분자 역학 시뮬레이션 패키지- 집에 그런 양념이 더 있나요?껍질일반적으로 Linux(또는 UNIX)에서는?


1- 기억해 두시면 좋아요cowsay명령이나 스크립트의 출력과 같이 행운뿐만 아니라 모든 인수를 출력할 수 있습니다 cowsay -s $(script_in_path_or_command). 참고 -s는 여기서 소의 모양을 나타냅니다. 맨페이지를 참조하세요.

답변1

PS1좋아, and 를 사용하면 command_not_found_handlebash가 당신을 모욕하도록 할 수 있습니다:

anthony@Watt:~$ . /tmp/insult.sh 
anthony@Watt:~$ sl
bash: sl: command not found, incompetent spoony bard
anthony@Watt:~$ ls /wrong/path
ls: cannot access /wrong/path: No such file or directory
Learn to type, second-rate Horrified Heron.
anthony@Watt:~$ 

그리고 여기에 /tmp/insult.sh제가 위에서 출처를 적은 것이 있습니다.

### Data ###
bash_insulter_sentences=(
    'Have you considered Windows, %s?\n'
    'Learn to type, %s.\n'
    'Fell asleep at the keyboard again, %s?\n'
    "Failure is common when you're a %s, isn't it?\n"
)

bash_insulter_subjects=(
    'spoony bard'           # we all played this, right?
    'extra-Warty Warthog'
    'Dazed Drake'
    'Fidgety Fawn'
    'Horrified Heron'       # etc.
)

bash_insulter_adjectives=(
    'incompetent ' # these have built-in spacing
    'inept '
    'second-rate '
    '' # chance of none
    ''
)

### Functions to generate insults ###
bash_insulter_random_element() {
    if [ ${BASH_VERSINFO[0]} -lt 4 ] || \
        [ ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -lt 3 ]; then
        # bash before 4.3 doesn't have -n
        eval "local var=(\"\${$1[@]}\")"
    else
        local -n var="$1"
    fi
    local len=${#var[@]}
    echo -n "${var[$RANDOM % len]}" # Slightly biased. Don't care.
}

bash_insulter_full_subject() {
    bash_insulter_random_element bash_insulter_adjectives
    bash_insulter_random_element bash_insulter_subjects
}

bash_insulter_do_insult() {
    printf "$(bash_insulter_random_element bash_insulter_sentences)" "$(bash_insulter_full_subject)"
}

### set up ###
command_not_found_handle() {
    echo "bash: $1: command not found, $(bash_insulter_full_subject)"
    return 127
}

PS1='`
    if [ 0 -ne $? -a 127 -ne $? ]; then
        bash_insulter_do_insult
    fi
    echo "\u@\h:\w\$ "; 
`'

답변2

누군가 언급함sl. 최대한의 예측 가능성을 목표로 하는 인터프리터와 같은 소프트웨어에서는놀라다문맥 상 확실히 "공격적"인 것으로 간주됩니다. 설명서에는 적절한 옵션도 나열되어 있습니다.

DESCRIPTION
   sl  is a highly advanced animation program for curing your bad habit of
   mistyping.

   -a     An accident is occurring. People cry for help.

   -l     Little version

   -F     It flies like the galaxy express 999.

   -c     C51 appears instead of D51.

...그리고 흥미로운 점은벌레:

BUGS
   It sometimes list directory contents.

관련 정보