Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bb9aee4
Kickoff the stdlib
katcipis Jun 29, 2017
bcc89e9
Add println skeleton
katcipis Jun 29, 2017
79ec23e
Add docs for fmt_println
katcipis Jun 30, 2017
b210479
Start to unify the build and install process
katcipis Jun 30, 2017
007a812
Add install with check
katcipis Jun 30, 2017
c227d1a
Add master install
katcipis Jun 30, 2017
e9f30df
Add version to nashfmt
katcipis Jun 30, 2017
0cf470f
remove vendor flag
katcipis Jun 30, 2017
ea4d50d
execute NASHPATH validation only on install
katcipis Jun 30, 2017
7b9653e
Fix release to contain bin and stdlib dirs on root
katcipis Jul 2, 2017
2d9602a
Add docs and automation for release install
katcipis Jul 2, 2017
d5851e2
Update TOCs
katcipis Jul 2, 2017
227a4b8
Add fmt_println implementation
katcipis Jul 2, 2017
b8c3653
Add stdlib on tries list
katcipis Jul 2, 2017
679da5d
stdlib is the last try
katcipis Jul 2, 2017
cdd33ff
Fix stupid bug
katcipis Jul 2, 2017
e0c3a44
Isolate setenv and unsetenv for each test
katcipis Jul 23, 2017
d3e418d
Add initial env tests
katcipis Jul 23, 2017
87ba285
Add first failing test for default NASHPATH
katcipis Jul 23, 2017
d5097e1
Write first test with some refactoring
katcipis Jul 23, 2017
a23eee5
Add default nashpath test
katcipis Jul 23, 2017
6ca1cd2
Add NASHROOT initial code
katcipis Jul 23, 2017
63c664a
Merge branch 'master' of github.com:NeowayLabs/nash into addStdlib
katcipis Jul 23, 2017
c34a15a
Add tests for default NASHROOT
katcipis Jul 23, 2017
ed3ecbe
Search stdlib on GOPATH if NASHROOT/HOME is unset
katcipis Jul 23, 2017
a676f0c
Add handling for invalid default HOME nashroot
katcipis Jul 23, 2017
1863392
Add tests validating when no env vars are set
katcipis Jul 30, 2017
f24c71d
Dont fail if no env vars is set
katcipis Jul 30, 2017
b283b64
Update env vars docs
katcipis Jul 31, 2017
025680b
Fix make install
katcipis Aug 7, 2017
7db531b
Remove unused guard clause
katcipis Aug 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
ifndef version
version=$(shell git rev-list -1 HEAD)
endif

buildargs = -ldflags "-X main.VersionString=$(version)" -v

all: build test install

build:
cd cmd/nash && make -e build
cd cmd/nashfmt && make -e build
go build $(buildargs) -o ./cmd/nash/nash ./cmd/nash
go build $(buildargs) -o ./cmd/nashfmt/nashfmt ./cmd/nashfmt

NASHPATH=$(HOME)/nash
NASHROOT=$(HOME)/nashroot

install: build
@echo
@echo "Installing nash at: "$(NASHROOT)
mkdir -p $(NASHROOT)/bin
rm -f $(NASHROOT)/bin/nash
rm -f $(NASHROOT)/bin/nashfmt
cp -p ./cmd/nash/nash $(NASHROOT)/bin
cp -p ./cmd/nashfmt/nashfmt $(NASHROOT)/bin
rm -rf $(NASHROOT)/stdlib
cp -pr ./stdlib $(NASHROOT)/stdlib

deps:
go get -v -t golang.org/x/exp/ebnf
Expand All @@ -14,14 +34,10 @@ docs: docsdeps
mdtoc -w ./README.md
mdtoc -w ./docs/interactive.md
mdtoc -w ./docs/reference.md
mdtoc -w ./docs/stdlib/fmt.md

test: deps build
GO15VENDOREXPERIMENT=1 ./hack/check.sh

install:
cd cmd/nash && make -e install
cd cmd/nashfmt && make -e install
@echo "Nash installed on $(GOPATH)/bin/nash"
./hack/check.sh

update-vendor:
cd cmd/nash && nash ./vendor.sh
Expand Down
48 changes: 42 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<!-- mdtocstart -->

# Table of Contents

- [nash](#nash)
- [Show time!](#show-time)
- [Useful stuff](#useful-stuff)
- [Why nash scripts are reliable?](#why-nash-scripts-are-reliable)
- [Installation](#installation)
- [Release](#release)
- [Linux](#linux)
- [Master](#master)
- [Getting started](#getting-started)
- [Accessing command line args](#accessing-command-line-args)
- [Namespace features](#namespace-features)
Expand All @@ -16,7 +20,9 @@
- [Security](#security)
- [Concept](#concept)
- [Motivation](#motivation)
- [Releasing](#releasing)
- [Want to contribute?](#want-to-contribute)

<!-- mdtocend -->

# nash
Expand Down Expand Up @@ -50,14 +56,44 @@ Nash is a system shell, inspired by plan9 `rc`, that makes it easy to create rel

## Installation

If you have Go, go-get it:
Before proceeding to any of the install procedures it is important that you

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where will the user set this environment variable? I think this is confusing because nash will init their environment from $NASHPATH/init, but NASHPATH needs to be set in the first place... But how if nash is the login shell? You mean to place the NASHPATH env config inside /etc/profile ?

@i4ki i4ki Jul 31, 2017 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought more about this and I think is useful for this behaviour to work when someone wants to put their NASHPATH somewhere else other than the default path. But I think it should not be the default way of installing nash, because it requires another login shell or root access to /etc/profile.d

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wish to improve this docs it will be welcomed, I think you understand this better =)

set in your environment the **NASHPATH** and **NASHROOT** variables.

```sh
# Make sure GOPATH/bin is in your PATH
go get github.com/NeowayLabs/nash/cmd/nash
go get github.com/NeowayLabs/nash/cmd/nashfmt
The **NASHROOT** variable is used to find the stdlib, while **NASHPATH**
is used to find libraries in general. It is important to have two different
paths since this will allow you to delete all libraries
(cleaning up your installation) by removing your $NASHPATH directory
without affecting your base nash installation and standard library.

If no **NASHPATH** set a default of $HOME/nash will be assumed.
If no **NASHROOT** set a default of $HOME/nashroot will be assumed.

The libraries lookup dir will be $NASHPATH/lib.
The standard library lookup dir will be $NASHROOT/stdlib.

After installing the nash binary will be located at $NASHROOT/bin.

### Release

Installing is so stupid that we provide small scripts to do it.
If your platform is not supported take a look at the existent ones
and send a MR with the script for your platform.

#### Linux

Run:

```
./hack/install/linux.sh
```

### Master

Run:

```
make install
```
If not, [download the latest binary release](https://github.com/NeowayLabs/nash/releases) and copy to somewhere in your PATH.

## Getting started

Expand Down
14 changes: 0 additions & 14 deletions cmd/nash/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/nash/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func main() {

if version {
fmt.Printf("build tag: %s\n", VersionString)
os.Exit(0)
return
}

if len(flag.Args()) > 0 {
Expand Down
7 changes: 0 additions & 7 deletions cmd/nashfmt/Makefile

This file was deleted.

9 changes: 9 additions & 0 deletions cmd/nashfmt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import (

var (
overwrite bool
version bool
// version is set at build time
VersionString = "No version provided"
)

func init() {
flag.BoolVar(&overwrite, "w", false, "overwrite file")
flag.BoolVar(&version, "version", false, "Show version")
}

func main() {
Expand All @@ -26,6 +30,11 @@ func main() {

flag.Parse()

if version {
fmt.Printf("build tag: %s\n", VersionString)
return
}

if len(flag.Args()) <= 0 {
flag.PrintDefaults()
return
Expand Down
2 changes: 2 additions & 0 deletions docs/interactive.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<!-- mdtocstart -->

# Table of Contents

- [Line mode](#line-mode)
- [Autocomplete](#autocomplete)
- [Hooks](#hooks)
- [bindfn](#bindfn)

<!-- mdtocend -->

When used as an interactive shell, nash supports a few features to
Expand Down
42 changes: 39 additions & 3 deletions docs/reference.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
<!-- mdtocstart -->

# Table of Contents

- [Command line arguments](#command-line-arguments)
- [Flow control](#flow-control)
- [Branching](#branching)
- [Looping](#looping)
- [Lists](#lists)
- [Forever](#forever)
- [Functions](#functions)
- [Operators](#operators)
- [+ (Concatenation)](#-concatenation)
- [+](#)
- [string](#string)
- [Packages](#packages)
- [Iterating](#iterating)
- [Built-in functions](#builtin-functions)
- [print](#print)
- [format](#format)
- [len](#len)
- [append](#append)
- [Packages](#packages)
- [exit](#exit)
- [glob](#glob)
- [Standard Library](#standard-library)

<!-- mdtocend -->

Here lies a comprehensive reference documentation of nash
Expand Down Expand Up @@ -171,10 +182,19 @@ echo $a+$b
#Output:"12"
```

# Packages

TODO

# Iterating

TODO

# Built-in functions

Built-in functions are functions that are embedded on the
language. You do not have to import any package to use them.

## print

The function **print** is used to print simple
Expand Down Expand Up @@ -237,4 +257,20 @@ example_list <= append($example_list, "2")
echo $example_list
```

# Packages
## exit

TODO

## glob

TODO

# Standard Library

The standard library is a set of packages that comes with the
nash install (although not obligatory).

They must be imported explicitly (as any other package) to
be used.

* [fmt](docs/stdlib/fmt.md)
21 changes: 21 additions & 0 deletions docs/stdlib/fmt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- mdtocstart -->

# Table of Contents

- [fmt](#fmt)
- [fmt_println](#fmtprintln)

<!-- mdtocend -->

# fmt

## fmt_println

Same behavior as print but adds a newline on the end.

```nash
import fmt

fmt_println("hi")
#Output:"hi\n"
```
4 changes: 4 additions & 0 deletions hack/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ done

$GO tool cover -func coverage.txt

echo "running stdlib tests"
export NASHPATH=`pwd`
./cmd/nash/nash ./stdlib/fmt_test.sh

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


# To submit the test coverage result to coveralls.io,
# use goveralls (https://github.com/mattn/goveralls)
# goveralls -coverprofile=profile.cov -service=travis-ci
13 changes: 13 additions & 0 deletions hack/install/linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the use case for this script?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing a nash release (instead of the master)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but someone will download the entire source code to just invoke a script that downloads the binary release?
Or you mean to installations like below?

$ curl https://raw.githubusercontent.com/NeowayLabs/nash/master/hack/install/linux.sh | bash -

If this is the case, then better to update the README explaining the right way of invoking this script.


set -o errexit
set -o nounset

VERSION="v0.5"
echo "installing nash: "$VERSION" at NASHPATH: "$NASHPATH

cd $NASHPATH
tarfile="nash-$VERSION-linux-amd64.tar.gz"
wget https://github.com/NeowayLabs/nash/releases/download/$VERSION/$tarfile
tar xvfz $tarfile
rm -f $tarfile
50 changes: 38 additions & 12 deletions hack/releaser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@ mkdir -p dist
fn prepare_execs(distfiles, os) {
if $os == "windows" {
newfiles = ()

for distfile in $distfiles {
file = $distfile+".exe"

newfiles <= append($newfiles, $file)
src = $distfile[0]
dst = $distfile[1]
newsrc = $src + ".exe"
newdst = $dst + ".exe"
newfiles <= append($newfiles, ($newsrc $newdst))
}

return $newfiles
}

if $os == "linux" {
for distfile in $distfiles {
strip $distfile
strip $distfile[0]
}
}

Expand All @@ -45,13 +48,36 @@ for os in $supported_os {
echo "building OS: "+$GOOS+" ARCH : "+$GOARCH
make build "version="+$version

nash = "cmd/nash/nash"
nashfmt = "cmd/nashfmt/nashfmt"
execfiles = ($nash $nashfmt)
pkgdir <= mktemp -d
bindir = $pkgdir + "/bin"
stdlibdir = $pkgdir + "/stdlib"
mkdir -p $bindir
mkdir -p $stdlibdir

nash_src = "./cmd/nash/nash"
nash_dst = $bindir + "/nash"
nashfmt_src = "./cmd/nashfmt/nashfmt"
nashfmt_dst = $bindir + "/nashfmt"

execfiles = ( ($nash_src $nash_dst) ($nashfmt_src $nashfmt_dst) )
execfiles <= prepare_execs($execfiles, $os)

# TODO: Improve with glob, right now have only one package =)
distfiles <= append($execfiles, ("./stdlib/fmt.sh" $stdlibdir))

for distfile in $distfiles {
src = $distfile[0]
dst = $distfile[1]
cp -pr $src $dst
}

distfiles <= prepare_execs($execfiles, $os)
distar <= format("dist/nash-%s-%s-%s.tar.gz", $version, $os, $arch)
projectdir <= pwd
distar <= format("%s/dist/nash-%s-%s-%s.tar.gz", $projectdir, $version, $os, $arch)

tar cvfz $distar $distfiles
chdir($pkgdir)
pkgraw <= ls
pkgfiles <= split($pkgraw, "\n")
tar cvfz $distar $pkgfiles
chdir($projectdir)
}
}
Loading