Skip to content

Mia-Rain/shm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

---
shm
-- sh en/decoder for faster writing
---
Deprecated
-- shm is deprecated in favor of milang
-- projects in shm should continue in pure sh
-- until mios/milang reach alpha
---
Usage
-- encode
  >> ./shm ./sh
-- decode
  >> ./shm ./shm
-- shebang
  >> #!/usr/bin/env shm 
  >>>> ./shm will auto decode shm code
  >>>> add -i to write output to ${file%.shm}
  >>>>>> write will fail if original file is same as ${file%.shm}
  >>>> ./shm will also auto encode shell code
  >>>>>> ALWAYS check en/decoded code before use
  >>>>>> NO code is ever perfect, and shm certainly isn't either
  >>>>>>>> ./shm does not work with STDIN ...
---
What?
-- shm encodes POSIX sh to shm and decodes shm to POSIX sh
---- shm replaces some POSIX sh builtins with shorthands
---- much like true & false have : & !
---- shm can be written using only ASCII symbols
---- but also features letter equivalents 
---
Dictionary
-- :    -- true  | !    -- false
-- ::/w -- while | !!/u -- until | ;;/n -- done
-- **/f -- for   | >:/i -- in    | ;/d  -- do
-- :*/c -- case  | *:/s -- esac  
-- :-/r -- read
-- -;/e -- echo  | -:/p -- printf
-- ()/o -- EOF
---
Syntax changes
-- shm applies some syntax changes, they are as follows
---- for:
  >> for i in  -- incorrect
  >> for $i in -- correct
  >>>> this change allows for i to replace in
---- read:
  >> read REQUIRES -r
  >> read -r   -- correct
  >>>> this is due to issues with -r matching r
  >>>> expecting -r fixes this & -r should always be used
---- functions:
  >> functions should NOT be a single letter
  >>>> this is to prevent calling functions from colliding with shm
---- piping:
  >> DO NOT pipe into a loop; use EOF/heredocs instead
  >>>> if you do pipe into a loop, shm will not catch it!
---
Decoding changes
-- as a compiler of sorts, shm may create optimizations or improvements
-- they are as follows
---- e/echo
  >> e "$item"
  >>>> will not actually produce an echo(1) call
  >>>> instead converts to printf(1) call
  >>>> this prevents issues with echo compatibility
  >>>>>> but may cause issues due to printf options
  >>>>>> YMMV; idc
---
Style
-- below are suggestions for coding style
---- they are not currently enforced but could be in the future
  >> following them is highly recommended
---- case:
  >> item)  -- incorrect
  >> (item) -- correct
  >>>> (item) ...    -- incorrect
  >>>> (item) ...;;  -- correct
  >>>> all lines in case should end with ;;
  >>>> however there must /NOT/ be a space before ;;
---- comments:
  >> item # ... -- incorrect
  >> item
     # ...      -- correct
  >>>> this is a very recent change, existing code might not follow
  >>>> comments always refer to the line above
  >>>>>> unless an arrow is present
---- functions: 
  >> func()
     {          -- incorrect
  >> func() {   -- correct
---- if:
  >> make use of &&/|| unless if makes more sense
  >> do not use if without a reason
---
Caveats
-- lines MUST not have trailing white-space
---

About

precursor to milang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages