emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tree-sitter shell script changes


From: Po Lu
Subject: tree-sitter shell script changes
Date: Fri, 10 Mar 2023 21:05:37 +0800

I would like to install the following two changes to avoid POSIX-isms
and bashisms in admin/notes/tree-sitter.  Would people please try them
first, to make sure that I did not break something obscure?

Thanks in advance.

diff --git a/admin/notes/tree-sitter/build-module/batch.sh 
b/admin/notes/tree-sitter/build-module/batch.sh
index 58272c74549..7ed57206619 100755
--- a/admin/notes/tree-sitter/build-module/batch.sh
+++ b/admin/notes/tree-sitter/build-module/batch.sh
@@ -1,27 +1,27 @@
-#!/bin/bash
+#!/bin/sh
 
-languages=(
-    'bash'
-    'c'
-    'cmake'
-    'cpp'
-    'css'
-    'c-sharp'
-    'dockerfile'
-    'go'
-    'go-mod'
-    'html'
-    'javascript'
-    'json'
-    'python'
-    'rust'
-    'toml'
-    'tsx'
-    'typescript'
-    'yaml'
-)
+languages='
+    bash
+    c
+    cmake
+    cpp
+    css
+    c-sharp
+    dockerfile
+    go
+    go-mod
+    html
+    javascript
+    json
+    python
+    rust
+    toml
+    tsx
+    typescript
+    yaml
+'
 
-for language in "${languages[@]}"
+for treesit_word in $languages
 do
-    ./build.sh $language
+    ./build.sh $treesit_word
 done
diff --git a/admin/notes/tree-sitter/build-module/build.sh 
b/admin/notes/tree-sitter/build-module/build.sh
index 9dc674237ca..1ab3e3aa4a2 100755
--- a/admin/notes/tree-sitter/build-module/build.sh
+++ b/admin/notes/tree-sitter/build-module/build.sh
@@ -1,13 +1,13 @@
-#!/bin/bash
+#!/bin/sh
 
 lang=$1
-topdir="$PWD"
+topdir=`pwd`
 
-case $(uname) in
-    "Darwin")
+case `uname` in
+    Darwin)
         soext="dylib"
         ;;
-    *"MINGW"*)
+    *MINGW*)
         soext="dll"
         ;;
     *)
@@ -25,27 +25,27 @@ sourcedir=
 grammardir="tree-sitter-${lang}"
 
 case "${lang}" in
-    "dockerfile")
+    dockerfile)
         org="camdencheek"
         ;;
-    "cmake")
+    cmake)
         org="uyha"
         ;;
-    "go-mod")
+    go-mod)
         # The parser is called "gomod".
         lang="gomod"
         org="camdencheek"
         ;;
-    "typescript")
+    typescript)
         sourcedir="tree-sitter-typescript/typescript/src"
         grammardir="tree-sitter-typescript/typescript"
         ;;
-    "tsx")
+    tsx)
         repo="tree-sitter-typescript"
         sourcedir="tree-sitter-typescript/tsx/src"
         grammardir="tree-sitter-typescript/tsx"
         ;;
-    "yaml")
+    yaml)
         org="ikatyang"
         ;;
 esac
@@ -61,18 +61,15 @@ grammardir=
 
 cc -fPIC -c -I. parser.c
 # Compile scanner.c.
-if test -f scanner.c
-then
+if test -f scanner.c; then
     cc -fPIC -c -I. scanner.c
 fi
 # Compile scanner.cc.
-if test -f scanner.cc
-then
+if test -f scanner.cc; then
     c++ -fPIC -I. -c scanner.cc
 fi
 # Link.
-if test -f scanner.cc
-then
+if test -f scanner.cc; then
     c++ -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}"
 else
     cc -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}"


reply via email to

[Prev in Thread] Current Thread [Next in Thread]