Skip to content

kenhys/xyzsh

 
 

Repository files navigation

"xyzsh" shell script language

What is this software?

    An interactive shell script language on OSX, cygwin, Linux, FreeBSD. This features simple object oriented scripting with garbage collection, text processing like perl or ruby and containes manual for all inner commands with their samples. Offcourse you can type commands with completion which is based on xyzsh grammer like IDE and is defined by itself.

    > ls -F   docs/ main.c samples/ sub.c
        
    > ls | each ( | chomp | -d && | print )
    docs
    samples

    > ls -F | grep -v /
    main.c sub.c

    > ls | each ( ! | chomp | -d && | print )
    main.c sub.c

    > ls | each ( | printf "-+- %s -+-"\n ) | join " "
    -+- docs -+- -+- main -+- -+- samples -+- -+- sub.c -+-

    > ls | each ( | scan . | join " " )
    d o c s
    m a i n . c
    s a m p l e s
    s u b . c

    > cat data
    Gorou Yamanaka
    Rei Tanaka
    Yumiko Shiratori

    > cat data | each ( | =~ Yamanaka && | print )
    Gorou Yamanaka

    > cat data | lines 0 1
    Gorou Yamanaka
    Rei Tanaka
        
    > cat data | each ( | split | lines 1 0 | join )
    Yamanaka Gorou
    Tanaka Rei
    Shiratori Yumiko
        
    > vim student.xyzsh
    class Student ( 
        | var first_name second_name age country
        
        def show (
            var first_name second_name age country | printf "name: %s %s?nage: %s?ncountry: %s?n"
        )
    )
        
    object student
    student::run ( print "Yamanaka Gorou 23 Japan" | split | Student )
        
    > load student.xyzsh
    > student::show
    name: Yamanaka Gorou
    age: 23
    country: Japan

    > ls | scan . | while(| eval "|${I=1} print |>") (|> join ""; ++ I )
    A
    UT
    HOR
    SCHA
    NGELO
    GLICEN
    SEMakef
    ileMakef
    ile.inREA
    DMEREADME.
    jaUSAGEUSAG
    E.jacompleti
    on.xyzshconfi
    g.hconfig.h.in
    config.logconfi
    g.statusconfigur
    econfigure.inhelp
    .xyzshinstall.shli
    bxyzsh.1.7.0.dylibl
    ibxyzsh.1.dyliblibxy
    zsh.dylibmanread_hist
    ory.xyzshsrcxyzshxyzsh
    .dSYMxyzsh.xyzsh

    > ls | lines 0 1 | scan . | each ( | chomp | x 5 | pomch )
    AAAAA
    UUUUU
    TTTTT
    HHHHH
    OOOOO
    RRRRR
    SSSSS
    CCCCC
    HHHHH
    AAAAA
    NNNNN
    GGGGG
    EEEEE
    LLLLL
    OOOOO
    GGGGG

Compiled and tested xyzsh below Operating systems
    OSX 10.8.0
    FreeBSD 7.1-RELEASE-p16
    CentOS 5.8
    Oracle Solaris 11 Express

AUTHORS
    I am an English learner. So my English is poor. If you have some times, send E-mail to me to correct my English Documents.

ATTENSION
    Use this software on your own risk. Don't use this under importnat systems. I recommend that you use this on your personal systems. I can't take a responsibility on your works with xyzsh. And use this with understanding that this language is not high performance.

How to compile
    Before compiling xyzsh, you need to resolve dependencies below. You need development packages.(ex. ncurses-devel or libncurse-dev)

    gcc 
    GNU make
    libc
    libm 
    ncurses(w)
    editline
    oniguruma (which is a regex library)
    iconv

    Have you installed above libraries? You can type below commands to compile xyzsh.

    ./configure --with-optimize
    make
    sudo make install

    or

    ./configure --with-optimize
    make
    su
    make install
    exit

    Default prefix is /use/local/bin, so you need a root comission for make install.

    If you want to change an installed directory, type below

    ./configure --prefix=??? --with-optimize
    make
    sudo make install

    or

    ./configure --with-optimize
    make
    sudo make DESTDIR=??? install

    When you choise normal install, installed xyzsh to /usr/local/bin and setting files to /usr/local/etc/xyzsh.

    configure options are below.

    --prefix --> indicate installed directory. If you use --prefix=$HOME, xyzsh will be installed $HOME/bin, $HOME/etc. As default, prefix is /usr/local.
    --with-optimize --> compiled with optimize. Fast binary will be made.
    --with-onig-dir --> indicate oniguruma installed directory.
    --with-editline-dir --> indicate editline installed directory.
    --with-debug --> give -g option to CFLAGS and add a checking memory leak system to xyzsh.
    --with-gprof-debug --> give -pg option to CFLAGS
    --with-static --> make xyzsh without dynamic linked libraries.

    For Japanese options

    --with-migemo --> enable migemo_match inner command for Japanse
    --with-migemo-dir --> indicate migemo installed directory.
    --with-system-migemodir --> specify the directory of system migemo dictionary.

    xyzsh makes library, so add /usr/local/lib(or your installed directory)  to /etc/ld.so.conf and type below to refresh dynamic loarding searched path cache in the case of linux
    
    sudo ldconfig
    
    or

    su
    ldconfig
    exit

    If you don't have root comission, add the path to LD_LIBRARY_PATH environment variable.

with OS X
    You don't have to be setting on ldconfig, but you need to set DYLD_LIBRARY_PATH like below

    export DYLD_LIBRARY_PATH=/usr/local/lib

Used files
    /usr/local/bin/xyzsh --> a program
    /usr/local/share/doc/xyzsh/USAGE --> USAGE in English
    /usr/local/share/doc/xyzsh/USAGE.ja --> USAGE in Japanese
    /usr/local/share/doc/xyzsh/README --> README in English
    /usr/local/share/doc/xyzsh/README.ja --> README in Japanese
    /usr/local/share/doc/xyzsh/CHANGELOG --> CHANGELOG in English and Japanese
    /usr/local/share/man/man1/xyzsh.1 --> manual file
    /usr/local/etc/xyzsh/xyzsh.xyzsh --> a source setting file
    /usr/local/etc/xyzsh/completion.xyzsh --> a source completion setting file
    /usr/local/etc/xyzsh/help.xyzsh --> a source help setting file
    /usr/local/etc/xyzsh/read_history.xyzsh --> a source which reads command line history
    /usr/local/lib/xyzsh/*.so --> xyzsh C extension library
    ~/.xyzsh/xyzsh.xyzsh --> a source user setting file. xyzsh read this after /usr/local/etc/xyzsh.xyzsh
    ~/.xyzsh/history --> a command line history file
    ~/.xyzsh/macro --> macro which is runned by typing C-x on command line uses this file
    ~/.xyzsh/jump --> jump inner command uses this file
    ~/.xyzsh/menu --> menu inner command uses this file
    ~/.xyzsh/program --> program list which is entried to root object
    ~/.xyzsh/lib/*.so --> xyzsh C extension library for user

Encoding and Line field
    xyzsh script source file must be written with UTF-8 encode and LF Linefield. But, xyzsh can treat UTF8, EUCJP, and SJIS encodings and can treat LF, CR, LFCR line fields. (EUCJP and SJIS are for Japanese)
    You should run xyzsh as interactive shell on UTF-8 terminal.

Usage
    Type

    > ./xyzsh

    to use as interactive shell

    or

    > ./xyzsh -c "command"

    to run the command

    or

    > ./xyzsh (script file name)

    to run the script file

Files
    AUTHORS
    CHANGELOG --> a changing log 
    LINCENSE --> MIT License described file
    Makefile.in --> Source of Makefile
    README --> This file
    USAGE --> Usage
    config.h.in --> source of config.h
    configure --> configure program
    configure.in --> source of configure
    install.sh --> used by configure
    src/xyzsh.h --> xyzsh header file
    xyzsh.xyzsh --> xyzsh run time script
    completion.xyzsh --> xyzsh completion run time script
    src/xyzsh --> headers
    src/block.c --> code structure 
    src/env.c --> expand env
    src/cmd_ary.c --> inner commands which is related to array 
    src/cmd_loop.c --> inner commands which is related to loop
    src/cmd_base.c --> base inner commands 
    src/cmd_condition.c --> condition expression inner commands
    src/cmd_curses.c --> inner commands which manipulate text consoles.
    src/cmd_file.c --> inner commands which is related to file system.
    src/cmd_num.c --> math inner commands.
    src/cmd_obj.c --> object oriented system inner commands
    src/cmd_str.c --> inner commands which manipulate strings.
    src/curses.c --> manipulating text console.
    src/debug.c --> my debug system. for expample, detecting memory leak
    src/gc.c --> xyzsh object gabage collector
    src/interface.c --> related to interface code
    src/kanji.c --> treated utf-8 (or Japanese SJIS, EUCJP) code
    src/main.c --> main code
    src/object.c --> extra objects
    src/obj_list.c --> list container library 
    src/obj_hash.c --> hash container library
    src/obj_string.c --> string library
    src/obj_vector.c --> dynamic array library
    src/obj_nfun.c --> native function object
    src/obj_fd.c --> file discriptor object
    src/obj_extprog.c --> external program object
    src/obj_completion.c --> completion object
    src/obj_class.c --> class object
    src/obj_fun.c --> function object
    src/obj_user.c --> user object
    src/parser.c --> parser
    src/xyzsh.c --> xyzsh
    src/xfunc.c --> c library function castamized by me
    src/editline.c --> editline code for interactive shell
    src/run.c --> main engine for xyzsh
    src/stack.c --> xyzsh stack object manager
    src/editline/*.c --> editline C sources
    src/editline/*.h --> editline header
    src/load.c --> load

LINCENSE
    MIT LICENSE

    This software contains edlitline(libedit) sources.

About

Interactive shell and text processing tools

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 97.1%
  • C++ 2.8%
  • Shell 0.1%