Passing bash variable to jq

I have written a script to retrieve certain value from file.json. It works if I provide the value to jq select, but the variable doesn’t seem to work (or I don’t know how to use it). #!/bin/sh #this works *** projectID=$(cat file.json | jq -r ‘.resource[] | select(.username==”[email protected]”) | .id’) echo “$projectID” [email protected] #this does … Read more

How to test code dependent on environment variables using JUnit?

I have a piece of Java code which uses an environment variable and the behaviour of the code depends on the value of this variable. I would like to test this code with different values of the environment variable. How can I do this in JUnit? I’ve seen some ways to set environment variables in … Read more

How to set child process’ environment variable in Makefile

I would like to change this Makefile: SHELL := /bin/bash PATH := node_modules/.bin:$(PATH) boot: @supervisor \ –harmony \ –watch etc,lib \ –extensions js,json \ –no-restart-on error \ lib test: NODE_ENV=test mocha \ –harmony \ –reporter spec \ test clean: @rm -rf node_modules .PHONY: test clean to: SHELL := /bin/bash PATH := node_modules/.bin:$(PATH) boot: @supervisor \ … Read more

Get Environment Variable from Docker Container

What’s the simplest way to get an environment variable from a docker container that has not been declared in the Dockerfile? For instance, an environment variable that has been set through some docker exec container /bin/bash session? I can do docker exec container env | grep ENV_VAR, but I would prefer something that just returns … Read more

Setting PATH environment variable in OSX permanently

I have read several answers on how to set environmental variables on OSX as permanently. First, I tried this, How to permanently set $PATH on Linux/Unix? but I had an error message saying no such file and directory, so I thought I could try ~/.bash_profile instead of ~/.profile but it did not work. Second, I … Read more