Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8162885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:52:47+00:00 2026-06-06T18:52:47+00:00

#test code: #!/bin/bash #~/test/test.sh trap echo ‘testmessage’ DEBUG while : do echo abc sleep

  • 0
#test code:

#!/bin/bash
#~/test/test.sh
trap "echo 'testmessage'" DEBUG

while :
do
echo abc
sleep 6
done

#run it
~/test$sh test.sh

==============================

#result
=>   trap: DEBUG: bad trap  

==============================

?[shell debug] why my trap doesn’t work when the signal set as “DEBUG” fake signal,but report trap error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:52:49+00:00Added an answer on June 6, 2026 at 6:52 pm

    The error message “bad trap” is produced by ash, not bash. When you run sh test.sh the shebang line is irrelevant because you aren’t executing the script, you’re executing the program called “sh” with “test.sh” as an argument. The sh program (in your case a symlink to ash or dash, I bet) then does its best to run the script named in the argument. The shebang line would come into play if you ran the command ./test.sh (it’ll need +x permission first).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this bash code: #!/bin/bash ################################################### # Variables # BACKIFS=$IFS IFS=$'\n' db_file=$PWD/test path_db=$PWD
W/hen i run the following code snippet #!/bin/bash if [ foo = foo ];
#! /bin/bash dir=$(find . -type f) echo ${dir[0]} echo This is dir[0] echo ${dir[1]}
While I see how to have Perl trap Ctrl-C (sigint) in bash ; I'm
I've written a bash script with the following code: #! /bin/bash sc_files=`grep -l 'string'
I have the below code in a bash file called 'findError.sh': #!/bin/bash filename=$1 formatindicator=\|\
my test code is below: main1.c: #include <stdio.h> extern struct tt ; int main()
This is my test code: describe(Login, function(){ beforeEach(function(){ loadFixtures('login-fixture.html'); }) it(should enable the button
After working on some test code for open ID authentication, I had a break
Here is my test code: <script type=text/javascript> YUI({ modules: { 'jquery': { fullpath: 'script/lib/jquery.min.js'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.