Node

node-gyp

for compiling native addon modules for Node.js
https://zhuanlan.zhihu.com/p/164543031

spawn inherit

在使用 spawn 执行 shell 时,如需直接获取和在 bash/zsh 中执行相同的效果,可以直接使用配置 stdio: ‘inherit’

  1. const installCmd = spawn('yarn', ['install', '--force'], {
  2. cwd,
  3. stdio: 'inherit',
  4. });

设置了 inherit 的 spawn,是不可进行 stdout 和 stderr 监听的,所以这是两种不同的用法

  1. // installCmd.stdout.on('data', function (data) {
  2. // console.log(`${data.toString().trim()}`);
  3. // });
  4. // installCmd.stdout.on('end', function () {
  5. // });
  6. // installCmd.stderr.on('data', function (data) {
  7. // console.log(`install error: ${data}`);
  8. // });

Shell

查看可用 shell 列表

cat /etc/shells

  1. cat /etc/shells
  2. # List of acceptable shells for chpass(1).
  3. # Ftpd will not allow users to connect who are not using
  4. # one of these shells.
  5. /bin/bash
  6. /bin/csh
  7. /bin/dash
  8. /bin/ksh
  9. /bin/sh
  10. /bin/tcsh
  11. /bin/zsh

查看当前使用 shell

https://www.cnblogs.com/softwaretesting/archive/2012/02/14/2350688.html
ps | grep $$ | awk ‘{print $4}’

  1. ps | grep $$ | awk '{print $4}'
  2. /bin/zsh
  3. grep