2

As an example, I am trying to capture the raw commands that are output by the following script:

https://github.com/adampointer/go-deribit/blob/master/scripts/generate-models.sh

I have tried to following a previous answer:

BASH: echoing the last command run

but the output I am getting is as follows:

last command is gojson -forcefloats -name="${struct}" -tags=json,mapstructure -pkg=${p} >> models/${p}/${name%.*}_request.go

What I would like to do is capture the raw command, in other words have variables such as ${struct}, ${p} and ${p}/${name%.*} replaced by the actual values that were used.

How do I do this?

Mary
  • 1,005
  • 2
  • 18
  • 37

2 Answers2

2

At the top of the script after the hashbang #!/usr/bin/env bash or #!/bin/bash (if there is any) add set -x

set -x Print commands and their arguments as they are executed

0.sh
  • 2,659
  • 16
  • 37
0

Run the script in debug mode which will trace all the commands in the script: https://stackoverflow.com/a/10107170/988525.

You can do that without editing the script by typing "bash generate-models.sh -x".

Ian McGowan
  • 3,461
  • 3
  • 18
  • 23