简体   繁体   中英

How to convert a bash script to tcsh

function history_to_syslog {
    declare command
    remoteaddr="`who am i`"
    pwd="`pwd`"
    command=$(fc -ln -0)
    if [ "$command" != "$old_command" ]; then
        logger -p local2.notice -t bash -i ? "$USER : $remoteaddr" \
        "Command : $command  Directory : $pwd"
    fi
    old_command=$command
}
trap history_to_syslog DEBUG

How do I change to change the bash scripts to tcsh?

To change a script from bash to csh, you first need to learn about the differences between the different shell environments. For example study this guide on http://hyperpolyglot.org . You might learn, that the vast majority is equivalent. Some syntax can directly be translated into each other. However, some syntax is too specific to its shell to be directly translatable.

Your next step is to identify which parts of your code can be translated directly, and which parts do not have a 1-to-1 translation - and therefore need another implementation csh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM