Author Archives: Jeffrin

Hacking with Makefile for machine architecture detection

# SPDX-License-Identifier: GPL-2.0 INCLUDEDIR := -I. CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g TEST_GEN_FILES := adi-test UNAME := $(shell uname -m) all: $(TEST_GEN_FILES) $(TEST_GEN_FILES): adi-test.c ifeq ($(UNAME), sparc64) $(info Machine architecture does match) else $(info exit) $(error Machine architecture does not match) endif TEST_PROGS := drivers_test.sh include ../../lib.mk $(OUTPUT)/adi-test: adi-test.c

Look into bash builtin command named typeset

$typeset -n gree=55 bash: typeset: 55′: invalid variable name for name reference $typeset -n 55=gree bash: typeset:55=gree’: not a valid identifier$typeset -n gree=pwd$echo $gree $echo $pwd $typeset -n vary=$?bash: typeset: `0′: invalid variable name for name reference$typeset vary=$?$echo $vary1$echo $vary1$echo $?0$echo $vary1$echo varyvary$echo $vary1$echo $vary1$echo $?0$typeset vary=$?$echo $vary0$ $typeset hello $echo $hello $echo $? 0

How to use dirs, pushd and popd commands ?

$pushd upstream-kernel/ ~/upstream-kernel ~ $pwd /home/jeffrin/upstream-kernel $cd .. $pushd temp/ ~/temp ~ ~ $dirs ~/temp ~ ~ $dirs -l /home/jeffrin/temp /home/jeffrin /home/jeffrin $pwd /home/jeffrin/temp $pushd ../upstream-kernel/ ~/upstream-kernel ~/temp ~ ~ $dirs -l /home/jeffrin/upstream-kernel /home/jeffrin/temp /home/jeffrin /home/jeffrin $pushd ../testing/ ~/testing ~/upstream-kernel ~/temp ~ ~ $dirs -l /home/jeffrin/testing /home/jeffrin/upstream-kernel /home/jeffrin/temp /home/jeffrin /home/jeffrin $popd ~/upstream-kernel ~/temp ~ ~

finding source code or source file of a typical bash function

$type -a signals bash: type: signals: not found $type -a _signals _signals is a function _signals () { local -a sigs=($( compgen -P “$1” -A signal “SIG${cur#$1}” )); COMPREPLY+=(“${sigs[@]/#${1}SIG/${1}}”) } $declare -F _signals _signals $shopt -s extdebug $declare -F _signals _signals 862 /usr/share/bash-completion/bash_completion $declare -F _command _command 1732 /usr/share/bash-completion/bash_completion $declare -F compgen $declare -F _grub_dirs

compgen builtin command exposure

ABOUT compgen compgen is bash built-in command and it will show all available commands, aliases, and functions for you. TYPICAL COMMANDLINE EXPOSURE RELATED LINKS https://www.cyberciti.biz/open-source/command-line-hacks/compgen-linux-command/ https://www.gnu.org/software/bash/manual/html_node/A-Programmable-Completion-Example.html

bash builtin command named command

$pwd /home/jeffrin/upstream-kernel $tail ~/.bashrc . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi export PS1=$ function ls { pwd } $ls /home/jeffrin/upstream-kernel $command ls 0002-Testing-script-for-Intel-P-State-driver-crashes-duri.patch linux linux-kselftest linux-kselftest.bup linux-kselftest.bup2 linux-next linux.old $

caller — returns the context of any active subroutine call

$cat test.bash!/bin/bash die() { local frame=0 while caller $frame; do ((frame++)); done echo “$*” exit 1 } f1() { die “*** an error occured ***”; } f2() { f1; } f3() { f2; } f3 $ $bash test.bash 12 f1 test.bash 13 f2 test.bash 14 f3 test.bash 16 main test.bash *** an error occured ***