GithubHelp home page GithubHelp logo

nyxnor / scripts Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11 KB

Miscellaneous files to help you write smart shell scripts

Shell 100.00%
shell shellscript shellscript-tutorials posix posix-shell shell-script miscellaneous-scripts getopts getopt

scripts's Introduction

Scripts - Some critical relevant interesting parsimonious temendrous scripts

Useful configuration files and executables to facilitate every day development.

The intent of this repository is to be an advanced tutorial, but you will have to read scripts instead of markdown, paying attention to the code comments.


Table of Contents


Requirements

  • Unix like system with a POSIX compliant shell (sh, ash, dash, bash, ksh, zsh etc) and standard shell utilities (grep, sed, find etc).
  • Some shellscripting knowledge as this is not a begginers guide. To learn, see the reading topic.

Configuration files

  • .editorconfig - EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs
  • .shellcheckrc - Shellcheck run commands file

Scripts

  • check-progs.sh - check if program is installed (placed on PATH) and executable.
  • expansions.sh - useful expansions to get script name, correct folder path, assign default values if key is empty or unset.
  • formatting.sh - tips on formatting your scripts, dedicated to emphatization, colors, bold, underline, error messages.
  • getopts.sh - enhanced getopts to accept long and short options, as well as requiring arguments, checking if arguments are within range, setting default values to not brek tests and arguments expressed after an equal sign (--option=arg).
  • permission.sh - bulk/recursively permission set for all files and folders inside chosen directory. Commonly used with folder 755 and file 644, or folder 700 and file 600.
  • toc.sh - build markdown table of contents, check if header is repeated. Requires the header to be set by hashtag (#), not by equals (===) nor by hifens (---).

Reading

Materials referenced here are a must read before any question is asked.

Development

To add new scripts, the following rules will be taken into consideration:

Portability

  • POSIX compliant
  • Platform agnostic

Usability

  • It is faster to understand the options and run the script than to do the tasks manually

Coding style

  • Respects the coding standard or enhances it
  • Has code comments
  • Has usage message
  • Function names starts with a verb
  • Variables name starts with a noun

Syntax

scripts's People

Contributors

nyxnor avatar

Watchers

 avatar

scripts's Issues

getopts should accept short options combined

example is grep -qE. -q and -E are two options combined, they can't require argument, or probably just the last one can.
The script should loop all these options instead of erroring out if the options are valid.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.